Failing to cache requests

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Failing to cache requests

Andrei
Hello,

I'm having a hard time understanding why these requests aren't being cached for 10 minutes? Is it the cookies? If so how can I avoid this and force cache?

curl -I https://NNN.com/abc123/amp
HTTP/1.1 200 OK
Date: Sat, 21 Sep 2019 17:59:11 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Set-Cookie: __cfduid=d79327988a8ff43f308be68675eedfac31569088750; expires=Sun, 20-Sep-20 17:59:10 GMT; path=/; domain=.NNN.com; HttpOnly
Alternate-Protocol: 443:npn-http/2
Cache-Control: max-age=600
Cf-Railgun: direct (starting new WAN connection)
Expires: Sat, 21 Sep 2019 18:09:10 GMT
Last-Modified: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: pvc_visits[0]=1569175150b5472; expires=Sun, 22-Sep-2019 17:59:10 GMT; Max-Age=86400; path=/; secure; HttpOnly
Set-Cookie: cookielawinfo-checkbox-necessary=yes; expires=Sat, 21-Sep-2019 18:59:10 GMT; Max-Age=3600; path=/
X-Cache-Status: MISS-0
X-Pingback: https://NNN.com/abc123/xmlrpc.php
X-Request-Id: zbbdrnjacxubirpb
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 519dee748b7e91da-EWR

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Failing to cache requests

Francis Daly
On Sat, Sep 21, 2019 at 01:02:57PM -0500, Andrei wrote:

Hi there,

> I'm having a hard time understanding why these requests aren't being cached
> for 10 minutes? Is it the cookies?

Yes.

http://nginx.org/r/proxy_cache_valid

"""
If the header includes the “Set-Cookie” field, such a response will not be cached.
"""

> If so how can I avoid this and force cache?

"""
Processing of one or more of these response header fields can be disabled using the proxy_ignore_headers directive.
"""

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Failing to cache requests

Andrei
Hello,

Thanks for the confirmation! Is there a way to selectively ignore only specific "set-cookie"/cookies, versus all "set-cookie" headers to force cache? Or even better to remove/strip certain cookies with a regex match? I imagine this way I can strip the cookies that aren't relevant, it would cache on it's own, and if some new cookie appears it will avoid caching the request. I believe this might be doable using Lua, but I haven't had any luck :( 


On Sun, Sep 22, 2019 at 7:26 AM Francis Daly <[hidden email]> wrote:
On Sat, Sep 21, 2019 at 01:02:57PM -0500, Andrei wrote:

Hi there,

> I'm having a hard time understanding why these requests aren't being cached
> for 10 minutes? Is it the cookies?

Yes.

http://nginx.org/r/proxy_cache_valid

"""
If the header includes the “Set-Cookie” field, such a response will not be cached.
"""

> If so how can I avoid this and force cache?

"""
Processing of one or more of these response header fields can be disabled using the proxy_ignore_headers directive.
"""

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Failing to cache requests

Francis Daly
On Sun, Sep 22, 2019 at 09:37:51AM -0500, Andrei wrote:

Hi there,

> Thanks for the confirmation! Is there a way to selectively ignore only
> specific "set-cookie"/cookies, versus all "set-cookie" headers to force
> cache?

Not that I am aware of, for proxy_cache.

> Or even better to remove/strip certain cookies with a regex match?

Not that I am aware of.

If you do find a way, and it happens too late to affect proxy_cache,
then you can possibly get around that by doing two proxy_pass'es --
one with caching to another, which strips the Set-Cookie headers that
you don't want to see after proxy_pass'ing to the "real" upstream.


But you may be better off configuring the upstream server not to send
the Set-Cookie header that you don't want.

That would presumably be more reliable, if it is doable.

Good luck with it,

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Failing to cache requests

Andrei
Thanks for the input!

On Sun, Sep 22, 2019 at 3:07 PM Francis Daly <[hidden email]> wrote:
On Sun, Sep 22, 2019 at 09:37:51AM -0500, Andrei wrote:

Hi there,

> Thanks for the confirmation! Is there a way to selectively ignore only
> specific "set-cookie"/cookies, versus all "set-cookie" headers to force
> cache?

Not that I am aware of, for proxy_cache.

> Or even better to remove/strip certain cookies with a regex match?

Not that I am aware of.

If you do find a way, and it happens too late to affect proxy_cache,
then you can possibly get around that by doing two proxy_pass'es --
one with caching to another, which strips the Set-Cookie headers that
you don't want to see after proxy_pass'ing to the "real" upstream.


But you may be better off configuring the upstream server not to send
the Set-Cookie header that you don't want.

That would presumably be more reliable, if it is doable.

Good luck with it,

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx