Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 :)

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.