如何使用Nginx代理缓存来处理动态内容

时间:2014-05-30 17:33:57

标签: caching joomla nginx proxy

所以这让我很头疼,也许有人已经掌握了它。我有一个Joomla 2.5网站,有很多动态内容,但也是静态的。

这是我目前的配置。但我不能理解当网站输出会话cookie我不希望它缓存它。所以基本上(如果未注册/未登录,Deliever缓存内容。)

proxy_cache_path C:/Users/root/Desktop/nginx/cache levels=1:2 keys_zone=my-cache:8m max_size=1000m inactive=600m;
proxy_temp_path C:/Users/root/Desktop/nginx/temp/proxy_temp;

server {
listen   80;
listen   [::]:80;

server_name  domain.com

root   c:/server/websites/ps/public_www;
index index.php index.html index.htm default.html default.htm;

location / {
root   c:/server/websites/ps/public_www;

if ($cookie_session) { set $do_not_cache 1; }
if ($request_method = 'POST') { set $do_not_cache 1; }
if ($request_uri ~* "administrator") { set $do_not_cache 1; }

proxy_set_header X-Real-IP  $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass   http://127.0.0.1:8000;

# Define which cache to use
proxy_cache my-cache;
# Define which responses to cache and for how long
proxy_cache_valid  200 302  60m;
proxy_cache_valid  404      5m;
# Don't cache if our headers (or cookie) are present
proxy_no_cache $do_not_cache;
# Ignore the standard no-cache headers - these will still be sent to the browser
proxy_ignore_headers X-Accel-Expires Expires Cache-Control;
# Don't send our custom header to the browser
proxy_hide_header X-Dont-Cache-Me;
# This next line is important if we're planning on caching for more than one site on the server
proxy_cache_key "$scheme$host$request_uri";
proxy_cache_use_stale updating;

如果任何人都能提供帮助会非常非常烦人,它会缓存cookie(包括我登录时),并会将其发送给其他人。

0 个答案:

没有答案