Welcome! Log In Create A New Profile

Advanced

Homepage cache and cookies

March 24, 2016 09:14AM
I am trying to cache the home page to a site. I am only caching the home page. If I put in a condition to check for cookies existing before caching, everything works as expected, but there is a high BYPASS rate due to the client not having the cookies the first time they visit the site. Once I took out the check for cookies, clients started getting cached cookies from other users. Is there a way to still have the cookies set from the origin server, and have a cache hit?

server {
listen 80;

if ($request_uri !~* "home.html") {
set $skip_cache 1; }

location / {
proxy_pass http://backend;
proxy_set_header Host $host;
proxy_cache_bypass $skip_cache;
proxy_no_cache $skip_cache;
proxy_pass_header Set-Cookie;
proxy_cache one;
proxy_cache_key $scheme$proxy_host$uri$is_args$args$cookie_myCookie$cookie_myOtherCookie;
proxy_cache_valid 200 302 10m;
proxy_cache_valid 404 1m;
proxy_ignore_headers "Set-Cookie" "Cache-Control" "Expires";
proxy_hide_header "Set-Cookie";
proxy_cache_lock on;
if ($http_user_agent ~* '(iPhone|Android|Phone|PalmSource|BOLT|Symbian|Fennec|GoBrowser|Maemo|MIB|Minimo|NetFront|Presto|SEMC|Skyfire|TeaShark|Teleca|uZard|palm|psp|openweb|mmp|novarra|nintendo ds|hiptop|ipod|blackberry|up.browser|up.link|wap|windows ce|blackberry|iemobile|bb10)' ) {
proxy_pass http://backend_mobile; }
if ($http_user_agent ~* '(iPad|playbook|hp-tablet|kindle|Silk)' ) {
proxy_pass http://backend_tablet; }

root /opt/rh/rh-nginx18/root/usr/share/nginx/html;
index index.html index.htm;
}
Subject Author Posted

Homepage cache and cookies

john_smith77 March 24, 2016 09:14AM

Re: Homepage cache and cookies

B.R. March 24, 2016 01:06PM

Re: Homepage cache and cookies

john_smith77 March 24, 2016 04:31PM

Re: Homepage cache and cookies

B.R. March 25, 2016 04:40AM

Re: Homepage cache and cookies

john_smith77 March 25, 2016 09:06AM

Re: Homepage cache and cookies

john_smith77 March 25, 2016 05:33PM

Re: Homepage cache and cookies

ph.gras March 25, 2016 06:10PM

Re: Homepage cache and cookies

B.R. March 26, 2016 06:36AM

Re: Homepage cache and cookies

john_smith77 March 28, 2016 09:51AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 118
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready