Welcome! Log In Create A New Profile

Advanced

check a cookie and donot cache them

Posted by tolgaygul 
check a cookie and donot cache them
August 14, 2012 04:20AM
Hi,

Our developer had put a new cookie one of our domains thus we can understant which users visit via tablet or pc and I need to add new rule the set not to cache for tablets users. I found some information on internet but non of them work. how does the rule should be?


I addet the if statement but does't work and proxy_store off; is not working in if statement

****
proxy_cache_valid 200 302 5m;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 120;
proxy_send_timeout 120;
proxy_read_timeout 120;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
client_max_body_size 20m;
client_body_buffer_size 128k;
proxy_hide_header X-Powered-By;
**********

location / {

set $cache 0 ;

if ($http_cookie ~ 'device=tablet') {
set $cache 1;
break;
}

if ($cache = 1) {
proxy_pass http://backend;
break;
}

proxy_cache one;
proxy_cache_key backend$request_uri;
proxy_cache_use_stale error timeout invalid_header;
proxy_pass http://backend;
expires 300s;
break;
}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 176
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready