简体   繁体   中英

ImageResizer, azure cdn, cache busting and url rewrting

I am planning on using ImageResizer to dynamically resize images. The images will be stored on Azure blobs and accessed via CDN.

At the moment files paths are inline and in css:

<img src="/images/someimage.jpg" />

.backgroundImage { url('/images/somebgimage.jpg') 

1) What is a recommended way to redirect image paths to use CDN? I've seen people use Html Helpers (in asp.mvc @Html.CdnImage('/images/something.jpg')) but this doesn't work for images in css.

2) There is also url-rewriting in the web.config

Given that ImageResizer uses querystring to manipulate the images, how would you go about cache busting images after an update and how would you point images to use the CDN?

Client-side redirects massively increase latency, and should be avoided. You can't use URL-rewriting between different hosts.

Most CSS pre-processors support helper methods. If you can't use helpers everywhere, manually insert the CDN addresses.

Cache-busting is CDN-specific. Changing the URL works everywhere (unless you disable querystring-specific caching on your CDN). Some CDNs also offer an invalidation API. Either way, I would open a question about the specific CDN you are using as this isn't an ImageResizer question.

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