Welcome! Log In Create A New Profile

Advanced

load balancing and caching combination problem

August 31, 2009 04:57AM
I just installed nginx 0.8.11 in order to use the $upstream_cache_status variable.

I can see now in the logs that my URLs (ics feed URLs) are cached and retrieved from the cache (MISS, HIT, EXPIRED) based on my caching parameters.

But, it only works when
proxy_ignore_headers Cache-Control;
proxy_ignore_headers Expires;

are used and left uncommented. I have read in the forums that this shouldn't be use in production. So what should I do next to be able to comment these parameters and get the result I'm expected.

I tried to set the Expires header by using set_proxy_header, but no headers are added to my file. Here is my configuration file and the headers of one the ICS file

[b]nginx.conf[/b]

user www-data;
worker_processes 4;

error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;

events {
worker_connections 4096;
}

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

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

access_log /var/log/nginx/access.log fbcal;

sendfile on;

keepalive_timeout 30;
tcp_nodelay on;

include /etc/nginx/app-servers.include;

proxy_cache_path /var/www/fbcaldotcom/cache levels=1:2 keys_zone=one:10m;
proxy_temp_path /temp/cache;

server {
listen 80;

if ( $remote_addr = 127.0.0.1 ) {
rewrite ^(.*)$ /500.html last;
return 302;

}

location / {
proxy_pass http://backend;

proxy_cache one;
proxy_cache_key backend$request_uri;
proxy_cache_valid 200 3h;
proxy_cache_use_stale error timeout invalid_header;
# proxy_ignore_headers Cache-Control;
# proxy_ignore_headers Expires;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

error_page 500 501 = /500.html;
error_page 502 503 504 = /502.html;
}

location /500.html {
root /var/www/nginx-default;
}

location /502.html {
root /var/www/nginx-default;
}

}

}

[b]curl -I[/b]

HTTP/1.1 200 OK
Server: nginx/0.8.11
Date: Mon, 31 Aug 2009 08:41:57 GMT
Content-Type: text/calendar; charset=utf-8
Connection: keep-alive
X-Powered-By: PHP/5.2.4-2ubuntu5.7
Content-Disposition: attachment; filename="fbCal-Events.ics"
Cache-Control: max-age=10
Content-Length: 80450
Subject Author Posted

load balancing and caching combination problem

fredericsidler August 31, 2009 04:57AM

Re: load balancing and caching combination problem

Maxim Dounin August 31, 2009 06:18AM

Re: load balancing and caching combination problem

fredericsidler August 31, 2009 08:07AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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