简体   繁体   中英

dotent core blob storage caching

I have image processor app, for processing image and getting it from azure blob storage. In this moment my blob storage service is returning absolute url to image of blob return redirect to this url. For example:

 [Route("/blob-storage/{imageName}")]
 [HttpGet]
 public async Task<IActionResult> GetImage(string imageName, ImageSize size)
 {
     var imageUrl = await this.ImageProcessorFacade.GetImageUrl(imageName, size);

     return Redirect(imageUrl);
 }

Now I want to caching this returned image. Yes, exists ResponseCache attribute, but It doesn't me work with redirect and I thing that it is bad way to solving this problem. For get image, I call for example this: http://localhost/blob-storage/test.jpeg?size... And response is redirect to blob.windows.net/... etc.

Is there way, how to cache it? Thank you for your time!

I want to caching this returned image. Yes, exists ResponseCache attribute, but It doesn't me work with redirect and I thing that it is bad way to solving this problem. For get image, I call for example this: http://localhost/blob-storage/test.jpeg?size ... And response is redirect to blob.windows.net/... etc.

You call Redirect() method in your controller action to redirect to a specified URL, the HTTP Location header field will be returned in response. And then the user agent (eg a web browser) that is invited by a response with 3xx code will make a second request to the new URL specified in the location field, which happens on web browser side, you could not append or modify cache-related headers to response.

在此处输入图片说明

If you'd like to lower latency and faster delivery the images that stored in Azure blob storage, you could try to use the CDN .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM