Welcome! Log In Create A New Profile

Advanced

Nginx Cache Valid till - Help

November 14, 2010 12:10AM
Hi,

I have a issue my nginx cofig is working ok just i want cache to clear only once in 15 days.
But it is clearing everyday and new images showing on homepage ( we use random images hence on each refresh its new)
however with nginx it needs to show same page and images etc picked from cache.
It works ok for 24 hours then again refreshes all content...as if cache is clear.

Here is Nginx conf
------------------------
user nginx;
worker_processes 16;
worker_rlimit_nofile 100000;

error_log /var/log/nginx/error.log crit;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;

pid /var/run/nginx.pid;


events {
worker_connections 102400;
use epoll;
}


http {
proxy_cache_path /var/lib/nginx/tmp/cache1 levels=1:2 keys_zone=proxy_cache1:16m max_size=20g inactive=1d;
proxy_cache_path /var/lib/nginx/tmp/cache2 levels=1:2 keys_zone=proxy_cache2:16m max_size=40g inactive=30d;
proxy_temp_path /var/lib/nginx/tmp/proxy;

include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log off;# /var/log/nginx/access.log main;

sendfile on;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
gzip on;
gzip_static on;
gzip_comp_level 5;
gzip_min_length 1024;
keepalive_timeout 65;
-----------------------------------

Here is cache inc
-----------------------------------
access_log off;
location / {
proxy_pass http://96.30.58.176:80;
include /etc/nginx/generic.inc;
proxy_ignore_headers "Cache-Control" "Expires";
proxy_cache_key "$server_name$scheme$proxy_host$uri$is_args$args$cookie_sid";
proxy_cache proxy_cache1;
proxy_cache_use_stale updating error timeout invalid_header http_500;
proxy_cache_valid 15d;
}

location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar)$ {
proxy_pass http://96.30.58.176:80;
include /etc/nginx/generic.inc;
proxy_ignore_headers "Cache-Control" "Expires";
proxy_cache_key "$server_addr:$server_port$request_uri";
proxy_cache proxy_cache2;
proxy_cache_use_stale updating error timeout invalid_header http_500;
proxy_cache_valid 15d;
}
---------------------------------------

Here is site.conf in called conf.d called
----------------------------------------
server {
listen 96.30.58.176:8080;
server_name www.site.com;
include /etc/nginx/cache.inc;
location /nginx_status {
stub_status on;
}
if ($http_host ~* "^site\.com$"){
set $rule_0 1$rule_0;
}
if ($rule_0 = "1"){
rewrite ^/(.*)$ http://www.site.com/$1 permanent;
break;
}
}

Regards
Subject Author Posted

Nginx Cache Valid till - Help

rajivv November 14, 2010 12:10AM

Re: Nginx Cache Valid till - Help

t3hslr November 14, 2010 08:18AM

Re: Nginx Cache Valid till - Help

Maxim Dounin November 14, 2010 11:46AM

Re: Nginx Cache Valid till - Help

rajivv November 14, 2010 10:29PM

Re: Nginx Cache Valid till - Help

rajivv November 14, 2010 10:09PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 255
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