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.

For normal public pages & js I do a

proxy_cache             assets;
proxy_cache_key         backend$request_uri;
proxy_cache_valid       200 302 100d;
proxy_cache_valid  404      1m;
proxy_cache_use_stale   error timeout invalid_header;

to cache content.

Is there a per user or IP based caching mechanism that will allow me to cache content.

My primary intention is cache pages for a user for short durations like 30 seconds or a minute maximum to prevent fast refreshes.

I understand the implication with NAT. But I am fine with it.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Just add the appropriate information to the proxy_cache_key. If you want to cache per client address, add $remote_addr or $binary_remote_addr. If you want to differentiate based on a cookie, add $cookie_NAME to the key. You can see a lot of the available variables at http://wiki.nginx.org/HttpCoreModule#Variables .

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.