Reputation: 503
I am trying to force the cache of this type of files: css, woff, otf, js, jpg, jpeg, gif, png, ico, cur, gz, svg, svgz, mp3, mp4, ogg, ogv and files without extension.
I can cache some images and mp3 files, but the rest are always in a state: X-Cache MISS
proxy_cache_path /tmp/test keys_zone=test:10m loader_files=300 max_size=4g;
location ~* (^/.*(css|woff|otf|js|jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp3|mp4|ogg|ogv)$|^/web/image.*) {
proxy_cache test;
proxy_cache_methods GET HEAD;
proxy_cache_lock on;
proxy_ignore_headers Set-Cookie;
proxy_ignore_headers X-Accel-Expires;
proxy_ignore_headers Expires;
proxy_ignore_headers Cache-Control;
add_header Pragma "public";
add_header Cache-Control "public";
add_header X-Cache $upstream_cache_status;
access_log off;
expires 12h;
proxy_pass http://test;
}
GET:
Nginx:
THX
Upvotes: 2
Views: 4353
Reputation: 46
Try to add
proxy_cache_valid 200 1d;
to keep all files matching your location that have a http state of 200 for 1 day in cache
Upvotes: 3