FRiCKLE / ngx_cache_purge

nginx module which adds ability to purge content from FastCGI, proxy, SCGI and uWSGI caches.
http://labs.frickle.com/nginx_ngx_cache_purge/
Other
1.06k stars 311 forks source link

Flag as EXPIRED, don't delete #40

Open fgilio opened 8 years ago

fgilio commented 8 years ago

Hi!

When using 'fastcgi_cache_use_stale updating' we can rely on serving and expired cache while the upstream builds a fresh new copy. But if we delete the cache, there is no expired resource... of course, there is just nothing.

Imagine the situation in which you have a very active site, think a news site, and suddenly you experience a huge traffic spike. If we are serving fastcgi cached pages, everything goes well. But if editors update the content the cache gets purged (deleted), and every subsequent request go straight to the upstream (if using php5-fpm you can see an army of new processes firing up). If you are lucky everything would normalize in a while... If you aren't, it will all go to hell.

But if we have the ability to flag a cache as EXPIRED, we can leverage 'fastcgi_cache_use_stale updating' to serve the old copy while the new one is being built.

What do you guys think?

nikolay commented 8 years ago

This is a good idea!