Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here's the cache path configuration inside http{}

fastcgi_cache_methods   GET HEAD;
fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=website:10m inactive=1d max_size=10m;

Here's the config in virtualhost:

location ~* \.php$ {
    fastcgi_index   index.php;
    fastcgi_pass    unix:/var/run/php5-fpm/manageraddons.socket;
    include         fastcgi_params;
    fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    fastcgi_cache       website;
    fastcgi_cache_key         $host$uri$is_args$args;
    fastcgi_cache_valid       200 301 302 304 40s;
        fastcgi_cache_valid       any 5s;       

I create a simple php file, including the following lines:

echo time();

So, my intention is: When I access it for the first time, it prints me the current time. Since the page is now cached, the next time I try to access the page, should show me the older time, not the current. But every time I refresh the page, the content printed changes to. I need stop nginx to send requests to fastcgi, how to properly configurate nginx to do it?


share|improve this question
You didn't send any Cache-Control header! – Michael Hampton Jul 12 '13 at 4:00
I did, just forgot to mention that. Even still, that's no just for browser cache? – André Stein Jul 12 '13 at 4:28
You should edit your question, then. – Michael Hampton Jul 12 '13 at 4:29

Your Answer


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

Browse other questions tagged or ask your own question.