我可以caching页面在nginx重写规则?

nginx conf:

location / { rewrite ^/cache.html$ /cache.jsp last; } location ~ \.jsp { proxy_pass http://127.0.0.1:85; #if I add proxy_cache here,will be cache every JSP file,I don't want it } #location ~ \.html { #I want cache all ".html" page,but it's not work. #proxy_cache cache; #.... #} 

我使用重写规则将/cache.html映射到/cache.jsp

我想访问http // localhost / cache.html来caching页面,

但是访问http // localhost / cache.jsp与caching,

怎么做? 感谢帮助 :)

这不可能简单地使用重写规则。

您可以使其工作的唯一方法是代理回到页面并启用代理caching。

您可以编写自定义位置,使其仅caching特定的页面扩展名,并且可以使用if语句来设置一次性caching键,使其看起来像一个页面未caching,尽pipe实际上caching为1个视图。

如果你正在考虑进入真正的基于规则的caching领域,我build议使用Varnish。