如何在 Google App Engine 上基于 java 的 Maven 项目中利用浏览器缓存?
How to leverage browser caching in a java based maven project on Google App Engine?
一直在努力在 Google 的 page insights tool, but no matter what i try it won't recognize the .htaccess file (to leverage browser caching for images/font files). The file is currently in the root directory and just copied the .htaccess file from this boilerplate 上获得 100/100 分。
This question here 的答案是:
.htaccess is not directly supported and instead it uses the app.yaml
file to accomplish much of what .htaccess provides.
那么我们如何在基于 java 的 Maven 项目中利用浏览器缓存呢? (不使用 app.yaml)
我找不到任何关于它的文档...
您可以在 appengine-web.xml 文件中为特定静态文件处理程序配置缓存持续时间,如 here 所述。例如:
<static-files>
<include path="/**.png" expiration="4d 5h" />
</static-files>
或者您的处理程序可以通过向浏览器返回适当的 Cache-Control
和 Expires
HTTP headers 来设置缓存持续时间。
一直在努力在 Google 的 page insights tool, but no matter what i try it won't recognize the .htaccess file (to leverage browser caching for images/font files). The file is currently in the root directory and just copied the .htaccess file from this boilerplate 上获得 100/100 分。
This question here 的答案是:
.htaccess is not directly supported and instead it uses the app.yaml file to accomplish much of what .htaccess provides.
那么我们如何在基于 java 的 Maven 项目中利用浏览器缓存呢? (不使用 app.yaml)
我找不到任何关于它的文档...
您可以在 appengine-web.xml 文件中为特定静态文件处理程序配置缓存持续时间,如 here 所述。例如:
<static-files>
<include path="/**.png" expiration="4d 5h" />
</static-files>
或者您的处理程序可以通过向浏览器返回适当的 Cache-Control
和 Expires
HTTP headers 来设置缓存持续时间。