I'm trying to set up Nginx as a reverse proxy for my Rails application running on Unicorn.
My app has some public pages that I'd like to cache for a duration for 60 minutes, so I set the max-age header.
Furthermore I have added the proxy_cache option to my server block in Nginx.
proxy_cache default;
and defined this cache
proxy_cache_path /var/www/nginx_cache keys_zone=default:10m max_size=500m;
I have set up my application to add this header to my cachable responses
Cache-Control: max-age=3600, public
When a client hits the page on the first time, the page is rendered and a response is returned. However, on subsequently requests, nginx does not decrement the max-age counter.
As a result, a visitor may visit my page one minute before it expires, meaning he is seeing 59 minutes old content. But then keep this copy in his browser for another 60 minutes, before he'll get a new copy.
Can I get Nginx to subtract the time passed by, so if a visitor hits a page that has been in the Nginx cache for 25 minutes, the max-age will be 35 minutes (2100 seconds) ?
No comments:
Post a Comment