简体   繁体   English

ImageResizer,Azure CDN,缓存清除和网址重写

[英]ImageResizer, azure cdn, cache busting and url rewrting

I am planning on using ImageResizer to dynamically resize images. 我打算使用ImageResizer动态调整图像大小。 The images will be stored on Azure blobs and accessed via CDN. 图像将存储在Azure Blob上并通过CDN访问。

At the moment files paths are inline and in css: 目前,文件路径为内联且位于CSS中:

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

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

1) What is a recommended way to redirect image paths to use CDN? 1)建议使用什么方法重定向图像路径以使用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. 我见过人们使用HTML Helper(在asp.mvc @ Html.CdnImage('/ images / something.jpg')中),但这不适用于CSS中的图像。

2) There is also url-rewriting in the web.config 2)web.config中也有URL重写

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? 鉴于ImageResizer使用查询字符串来处理图像,在更新后如何处理缓存清除图像,以及如何将图像指向CDN?

Client-side redirects massively increase latency, and should be avoided. 客户端重定向会大大增加延迟,应该避免。 You can't use URL-rewriting between different hosts. 您不能在不同主机之间使用URL重写。

Most CSS pre-processors support helper methods. 大多数CSS预处理器都支持辅助方法。 If you can't use helpers everywhere, manually insert the CDN addresses. 如果您不能在任何地方使用助手,请手动插入CDN地址。

Cache-busting is CDN-specific. 缓存清除是特定于CDN的。 Changing the URL works everywhere (unless you disable querystring-specific caching on your CDN). 更改URL随处可见(除非您在CDN上禁用特定于查询字符串的缓存)。 Some CDNs also offer an invalidation API. 一些CDN还提供无效API。 Either way, I would open a question about the specific CDN you are using as this isn't an ImageResizer question. 无论哪种方式,我都会对您使用的特定CDN提出一个问题,因为这不是ImageResizer问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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