当缓存资产的查询字符串参数更改时,Akamai 是否从源拉取
所以,我想为我的 css 和 js 文件添加版本控制。我想要执行此操作的方法是将查询字符串附加到资产路径的末尾,这样
/foo/bar/baz.css
这将
/foo/bar/baz.css?version=1
适用于代理和浏览器缓存,但是,我想知道 Akamai 是否会知道这是一个新文件并重新请求它来自原始服务器吗?我的假设是它会从源服务器重新请求文件,但我想我会问是否有人确切知道。
So, I want to add versioning to my css and js files. The way I would like to do this is by appending a query string to the end of the asset path so
/foo/bar/baz.css
Becomes
/foo/bar/baz.css?version=1
This will work for proxies and browser cache, however, I was wondering if Akamai will know this is a new file and re-request it from the origin server? My assumption would be that it would re-request the file from the origin server but figured I'd ask if anyone knew for sure.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的。它匹配所有 GET 请求的确切 URL。
Yes. It matches exact URLs for all GET requests.
不完全是。这取决于 CDN 配置。查询字符串值通常不是缓存键的一部分。因此,在设置 CDN 交付配置时,请确保显式添加选项以将查询字符串作为缓存键的一部分包含在内。否则,您最终将提供不一致的版本,因为缓存键不会根据查询字符串值(在本例中为资产版本)而变化。
Not quite. It depends on the CDN configuration. Query String values are usually not part of the cache-key. So, when setting up the CDN delivery config, make sure you explicitly add the option to include the Query String as part of the cache-key. Otherwise, you will end up serving inconsistent versions due to having a cache key that does not vary based on the query string value, in this case, the asset version.
我更喜欢像“/css/DEVELOPER_BASE/foo/baz/style.css”这样的网址。
您的构建/部署脚本会进行全局查找,并将“/css/DEVELOPER_BASE/”替换为“/css/[version_number]/”。
要完成此操作,您有两个选择。
这将使您不必担心浏览器和 CDN 如何处理查询参数。
I prefer to have a url like '/css/DEVELOPER_BASE/foo/baz/style.css'.
Your build/deploy scripts do a global find and replace on '/css/DEVELOPER_BASE/' with '/css/[version_number]/'
To make this work you then have two options.
This will keep you from having to worry about how browsers and CDN's handle query parameters.