nginx 配置如下
map $sent_http_content_type $expires {
default off;
~image/ 1d;
}
server {
listen 80;
server_name xxx.xxx.com;
access_log logs/access.log main;
expires $expires;
location / {
proxy_pass http://10.0.0.1:25022/media/;
}
}
原理如下
- The default value is set to off, which will not add any caching control headers. It’s a safe bet for content we have no particular requirements on how the cache should work.
- The last setting is for ~image/, which is a regular expression that will match all file types containing image/ in their MIME type name (like image/jpg and image/png). Like stylesheets, there are often a lot of images on websites that can be safely cached, so we set this to max as well.
参考链接:
网友评论