Nginx cache files by mime type using ngx_srcache module

agentzh agentzh at gmail.com
Thu Jun 13 19:38:32 UTC 2013


Hello!

On Wed, Jun 12, 2013 at 3:51 AM, n1xman wrote:
> 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



More information about the nginx mailing list