Is it possible to caching reverse proxy with login user ? I’m trying to figure out how to do it on openresty , Now the status is “BYPASS” because im bypassing the cookie session.
I can make it “HIT” by not bypassing the cookie , but it doesn’t allow me to login the site,
here is my recent configuration that shown "BYPASS"
proxy_cache_path /tmp/nginx/cache levels=1:2 keys_zone=my-cache:8m max_size=1000m inactive=600m;
proxy_temp_path /tmp/nginx;
add_header X-Cache-Status $upstream_cache_status;
server {
location / {
set_by_lua $no_cache '
if ngx.var.cookie_COOKIE == "" or ngx.var.cookie_COOKIE == nil then
return 1
end
return ""
';
proxy_cache_bypass $no_cache;
proxy_no_cache $no_cache;
proxy_buffering on;
proxy_cache my-cache;
proxy_cache_valid 200 302 60m;
proxy_cache_valid 404 1m;
proxy_cache_revalidate on;
proxy_cache_min_uses 3;
proxy_cache_use_stale error timeout updating http_500 http_502
http_503 http_504;
proxy_cache_background_update on;
proxy_cache_lock on;
proxy_hide_header "Set-Cookie";
proxy_ignore_headers Cache-Control Expires Set-Cookie;
proxy_cache_key "$no_cache$scheme$request_method$host$request_uri$mobile_request";
The question is Is it possible to make it “HIT” and still allowed to login to the site ?
Is it possible to make it “HIT” and still allowed to login to the site ?