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;
#....
#}
I using a rewrite rule to mapping /cache.html to /cache.jsp
I want to access http//localhost/cache.html to cache page,
but access http//localhost/cache.jsp with out cache,
how to do? thanks for help :)
That is not possibly simply using rewrite rules.
The only way you could make it work is by proxying back to the page and enabling proxy caching.
You could write custom locations to have it only cache specific page extensions and you can use if statements to set one-off cache keys to make it appear like a page is uncached, even though it is actually cached for 1 view.
If you're thinking of stepping in to the realms of real rule-based caching I'd recommend using Varnish instead.