S
S
Sergey Pugovkin2020-08-29 16:10:28
PHP
Sergey Pugovkin, 2020-08-29 16:10:28

Why doesn't nginx update the fastcgi cache in this case?

fastcgi_cache_path /var/tmp/cache-html levels=1:2 keys_zone=cache_html:16m inactive=1y max_size=4g;


location /index.php {
    internal;
    try_files /index.php =403;
    include fastcgi_params;
    fastcgi_pass unix:/etc/alternatives/php-fpm.sock;
    set_by_lua_block $key {
        return ngx.var.request_language .. '/' .. ngx.var.request_uri:sub(1, (ngx.var.request_uri:find('?') or (ngx.var.request_uri:len() + 1)) - 1):gsub('[/\\]+', '/')
    }
    fastcgi_cache_key $key;
    fastcgi_cache cache_html;
    fastcgi_cache_min_uses 1;
    fastcgi_cache_lock on;
    fastcgi_cache_background_update on;
    fastcgi_cache_use_stale updating;
    gzip off;
    gunzip on;
}


php (fastcgi) sends the X-Accel-Expires (+ Expires) header in the response, and in accordance with it, nginx caches this response.
And it seems like the norms work, but occasionally it happens that the cache is not updated (that is, the old page is constantly displayed).
I found this page in the cache, I look - and indeed:
X-Accel-Expires: @1598649662
I.e. overdue yesterday.

In general, judging by the description of fastcgi_cache_background_update: on
Allows you to run a background subrequest to update an expired cache item while a stale cached response is being returned to the client. Using an obsolete cached response at the time it is being updated should be allowed
(allowed with fastcgi_cache_use_stale_updating: updating), it seems that the page simply has the status "updating" for some reason, but in fact there is no update.

So what happens? And what to do with it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question