Getting fastcgi_no_cache to cache the fresh response

I have been trying to find a good and standard way of invalidating nginx
fastcgi cache. Some time ago we had the fastcgi_cache_bypass filter
which was not completely implemented and didn’t work (and has been
removed from the wiki since). Now the only option seems to be

Is there a way to cache that fresh response from the backend when
fastcgi_no_cache is 1?

Like this:

  1. Nginx receives a request with fastcgi_no_cache 1
  2. Nginx skips cache and returns a fresh response from the backend
  3. Nginx stores that response in the cache
  4. All of the subsequent requests when fastcgi_no_cache 0 (with the same
    cache_key) return that latest cached response.


Posted at Nginx Forum:,191844,191844#msg-191844

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs