Fastcgi_cache

Hi,
I am trying setup fastcgi_cache.
Working fine… BUT I need bypass some pages… when theses pages have
header “no-cache”… but I dont know how to do this…
The rules for bypass using urls, work fine… like this:

if ($request_uri ~*
"(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)")
{
        set $cache_uri 'null cache';
    }

How can I bypass cache setting header page “no-cache” ?
Example, in varnish work fine:
if (req.http.Cache-Control ~ “no-cache”)
{
return (pipe);
}

thanks

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,251112,251112#msg-251112

Hello!

On Mon, Jun 23, 2014 at 10:56:17AM -0400, ariel_esp wrote:

    set $cache_uri 'null cache';
}

[/code]

How can I bypass cache setting header page “no-cache” ?
Example, in varnish work fine:
if (req.http.Cache-Control ~ “no-cache”)
{
return (pipe);
}

http://nginx.org/r/fastcgi_cache_bypass


Maxim D.
http://nginx.org/

Hi, I already try this… but… not work =/
when in the page, I do “shift+f5”, page is re-read “EXPIRED”… OK
but, this entering in the page, or do F5 … page = HIT cache…
In this specifics pages, I always put php header “cache-control, pragma,
etc” as “no-cache”, so, I want always get a new page from backend…
understand?

fastcgi_cache microcache;
fastcgi_cache_key
$scheme$request_method$host$request_uri$http_x_custom_header;
fastcgi_cache_valid any 1m;
proxy_cache_use_stale error timeout invalid_header updating http_500
http_502 http_503 http_504;
fastcgi_cache_lock on;
add_header Fastcgi-Cache $upstream_cache_status;

if ($cache_uri != “null cache”)
{
add_header Fastcgi-Cache $upstream_cache_status;
add_header X-Cache-Debug “$cache_uri $cookie_nocache
$arg_nocache$arg_comment $http_pragma $http_authorization”;
set $skip_cache 0;
}

fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;

fastcgi_cache_bypass $cookie_nocache $arg_nocache$arg_comment ;
fastcgi_no_cache $cookie_nocache $arg_nocache$arg_comment;

fastcgi_cache_bypass $http_pragma $http_authorization ;
fastcgi_no_cache $http_pragma $http_authorization;

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,251112,251115#msg-251115

Hello!

On Mon, Jun 23, 2014 at 01:08:33PM -0400, ariel_esp wrote:

Hi, I already try this… but… not work =/
when in the page, I do “shift+f5”, page is re-read “EXPIRED”… OK
but, this entering in the page, or do F5 … page = HIT cache…
In this specifics pages, I always put php header “cache-control, pragma,
etc” as “no-cache”, so, I want always get a new page from backend…
understand?

As long as response headers contain “Cache-Control: no-cache”,
nginx will not cache a response, unless explicitly asked to ignore
the Cache-Control header (using the fastcgi_ignore_headers
directive). No special handling is needed, it will just work.

If it doesn’t work for you, this likely means that:

  • either you did something wrong in your nginx config (i.e., used
    fastcgi_ignore_headers to disable Cache-Control handling);

  • or you wrote the “Cache-Control: no-cache” incorrectly.


Maxim D.
http://nginx.org/

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