How to cache the directory index, but not the content of it

mihaimustea nginx-forum at
Thu May 6 22:44:16 MSD 2010


I hope I won't ask a Mickey Mouse question, but I searched on the web and found nothing. Here is what I need to cache. Below is a summary of the tree of the website that I'm trying to cache:

/shop - i want to cache only the page requested like this (i cannot ask for index.php)
/shop/page.html - don't want to cache
/shop/dir - don't want to cache
/shop/dir/page.html - don't want to cache
/shop/img/*.(png|jpg|gif|css|js) - cache all static content (this i made it)
/shop/account/ - don't cache
/shop/account/login - cache (this i made it)

This is not actually the tree, but i have something like this. I tried different configurations, but none work (my main concern is to cache /shop because 50% of the hits are there). Can you please give me a hint? I'm not asking for the whole solution, just a hint. Probably there are some other guys looking for something like this and cannot find it (like me).

Below, you can find the part of the config that it's working at the moment:

	location ~* ^.*.(jpg|png|css|js|gif)$ {

	    proxy_cache example-images;

	    include	conf/proxy_general.conf;
	location /shop/customer/account/login/ {
	    proxy_cache example-login;

	    include	conf/proxy_general.conf;

	location  /shop/  {
	    proxy_cache example-shop;

	    include	conf/proxy_general.conf;

	location / {

	    include conf/proxy_general.conf;

and proxy_general.conf:

	proxy_ignore_headers "Cache-Control" "Expires";
	proxy_cache_valid  200 302 10m;
        proxy_redirect     off;
	proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_max_temp_file_size 0;

        client_max_body_size       100m;
        client_body_buffer_size    128k;

        proxy_connect_timeout      90;
        proxy_send_timeout         90;
        proxy_read_timeout         90;

        proxy_buffer_size          4k;
        proxy_buffers              4 32k;
        proxy_busy_buffers_size    64k;
        proxy_temp_file_write_size 64k;
	proxy_cache_use_stale  error timeout invalid_header updating http_500 http_502 http_503 http_504;


Thank you,


Posted at Nginx Forum:,83458,83458#msg-83458

More information about the nginx mailing list