我正在尝试根据 YSlow 准则在公共(public) Assets 上设置 future 的过期缓存,以启用从缓存加载并稍微提高性能。
根据documentation (参见底部的Cache-Control)这应该可以工作:
"assets.cache./public/javascripts/bootstrap.min.js"="max-age=315360000"
但事实并非如此,当我检查我得到的响应时:
Data Size 82002
Device disk
Expires Thu Jan 01 1970 01:00:00 GMT+0100 (IST)
Fetch Count 220
Last Fetched Sat Feb 25 2012 15:04:04 GMT+0000 (GMT)
Last Modified Sat Feb 25 2012 15:04:04 GMT+0000 (GMT)
我的文件存储在/public/javascripts/bootstrap.min.js下
我的路线条目是默认的:
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.at(path="/public", file)
如果我阅读source code for assets,配置似乎应该可以工作。 .
知道我缺少什么或如何让它发挥作用吗?
最佳答案
问题已解决:浏览器从自己的缓存中检索元素,但没有更新 Expires 条目。
几个小时没有使用该项目并且没有任何更改后,它就可以工作了。
哦,好吧...
关于caching - 如何在 Play 2.0 中设置 Assets 的 future 缓存控制过期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9445186/