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…
and hook this $no_proxy to ngx_srcache variables like I’m doing with
extension…?
location ~* \.(html)$ {
set $key $uri$args;
Just a side note: because you’re using the key in the “key” URI
argument below, you should escape it because the value may contain
special characters. That is,
set_escape_uri $key $uri$args;
And then in your location = /memc, you should unescape the “key” URI
argument like this:
set_unescape_uri $key $arg_key;
srcache_fetch GET /memc key=$key;
srcache_store PUT /memc key=$key&exptime=$ttl_1m;
proxy_pass http://www.example.com;
}
You can use the srcache_store_skip directive to achieve this:
However, I have noticed every srcache_fetch GET /memc subrequest hits
the
memcached even though srcache_store skipped content-type which is not
defined.
This will keep busy the memcached server and I think srcache_fetch GET
subrequest should not executed if srcache_store_skip triggered first. Or
am
I missing something here…
Thanks for the response. It is not happening on my uat site as I have
redone
the configuration and tested with the full setup. However it happened on
my
try out setup where I did not want image/* content-type to be cached.
2013/06/12 15:51:43 [info] 11016#0: *19 key: “%252fsanta.jpg” was not
found
by memcached while reading response header from upstream, client:
192.168.0.61, server: -, request: “GET /santa.jpg HTTP/1.1”, subrequest:
“/memc”
Maybe my configuration problem
Thanks again for the support and the setup is now cached by MIME types
also;
we are running ngx_srcache without a problem.
However, I have noticed every srcache_fetch GET /memc subrequest hits the
memcached even though srcache_store skipped content-type which is not
defined.
The cache fetch operation must be performed before sending a request
to the backend while the Content-Type response header is only
available after the backend request is already sent. You’re having a
chicken and egg problem here. And I don’t see how the srcache_fetch
can be skipped without a Content-Type response header available for
checks.
This will keep busy the memcached server and I think srcache_fetch GET
subrequest should not executed if srcache_store_skip triggered first.
Are you sure?
srcache_store_skip always runs after srcache_fetch for a particular
request. The caching workflow looks like this:
srcache_fetch
send backend request if it's a cache miss
receive backend response (headers)
srcache_store
I cannot see how srcache_store_skip can be triggered before
srcache_fetch without sending a backend request to get the
Content-Type response header.
Best regards,
-agentzh
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.