Nginx cache files by mime type using ngx_srcache module

n1xman nginx-forum at nginx.us
Tue Jun 11 09:10:20 UTC 2013


Hi,

I’m using ngx_srcache module with Memcached to cache static contents of the
upstream servers. This is based on static file extensions. Now I need to
cached them by looking at Content-Type of the header to cache .html pages as
we do not use the .html extension. (i.e.
http://www.example.com/this-is-my-site )

Is this possible with ngx_srcache module using map module or something
similar..

http {
map $upstream_http_content_type $no_proxy {
default 0;
~*^html/ 0;
}

and hook this $no_proxy to ngx_srcache variables like I’m doing with
extension…?

    location ~* \.(html)$ {
                        set $key  $uri$args;
                        srcache_fetch GET /memc key=$key;
                        srcache_store PUT /memc key=$key&exptime=$ttl_1m;
                        proxy_pass http://www.example.com;
                }

Any help to this is really appreciated.

Thanks in advance.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,240023,240023#msg-240023



More information about the nginx mailing list