Welcome! Log In Create A New Profile

Advanced

No caching static content.

Posted by pinger 
No caching static content.
July 12, 2013 05:51AM
I have some WCF-service on caching of images for our portal.
http://images.example.com/ImageProxy.ImageProxyService.svc/Image/Original/?uri=http://www.example.net/image.jpg
where:
[Original, Small, etc...] - size of image
http://www.example.net/image.jpg - source of image

I want to configure a server for caching on nginx too.
...
proxy_cache_path /var/cache/nginx/images levels=1:2 keys_zone=images:8m max_size=1000m inactive=600m;
...
server {
expires 24h;
add_header Cache-Control public;

listen 80;
server_name i.example.com;

location /img {
proxy_redirect off;
proxy_pass http://images.example.com/ImageProxy.ImageProxyService.svc/Image/;

proxy_cache images;
proxy_hide_header X-AspNet-Version;
proxy_hide_header X-Powered-By;
proxy_cache_valid 200 302 60m;
proxy_cache_valid 404 1m;
}

location ~* /Image {
rewrite ^/([^/]*)(.*)$ /img$2;
}
}

On request, nothing is cached. - http://images.example.com/img/Original/?uri=http://www.example.com/image.jpg (The picture is displayed in the browser.)
But if you place the image in the root of the server. The cache works. http://images.example.com/image.jpg

How can I make caching in my case?
Re: No caching static content.
July 18, 2013 08:17PM
Taking a total stab in the dark:
Have you tried
proxy_cache_min_uses 0;
?

Also I assume your back end is sending the appropriate caching headers? From the doco:

The following response headers flag a response as uncacheable unless they are ignored:

Set-Cookie
Cache-Control containing "no-cache", "no-store", "private", or a "max-age" with a non-numeric or 0 value
Expires with a time in the past
X-Accel-Expires: 0
Sorry, only registered users may post in this forum.

Click here to login

Online Users

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