Cache 404 & 500 pages

Maxim Dounin mdounin at mdounin.ru
Sun Jan 15 11:12:41 UTC 2012


Hello!

On Sun, Jan 15, 2012 at 12:27:41PM +0530, Quintin Par wrote:

> Hi all,
> 
> When I attempt caching these pages as shown below
> 
>         error_page  404        /404.html;
> 
>         location = /404.html {
> 
>                     root /var/www/prod /templates/;
> 
>                     internal;
> 
>                     add_header Cache-Control public;
> 
>                     add_header X-Cache-Status $upstream_cache_status;
> 
>                     proxy_cache             generalcache;
> 
>                     proxy_cache_key         backend$request_uri;
> 
>                     proxy_cache_use_stale   updating;
> 
>         }
> 
> I don’t see the X-Cache-Status header in the html response. Does that mean
> the page does not get cached?

The "proxy_cache" directive works if you are using proxy_pass.  It 
doesn't work if you are serving static files as in the config 
above.  This is expected behaviour.

Maxim Dounin



More information about the nginx mailing list