zoukankan      html  css  js  c++  java
  • nginx add CacheControl : public to static files

    On Tue, Oct 06, 2009 at 04:17:20AM +0200, Jauder Ho wrote:
    
    > > > Hi, I have nginx set up to serve static content and to set it to maximum > expires currently. However, I would also like to set the Cache-Control > flag to public so that proxies will know that this is okay to cache. > However, when I try this using the add_header directive, this adds an > additional Cache-Control: header instead of modifying the existing one. > > nginx config fragment: > location ~* ^.+\.(jpg|jpeg|gif|png|ico)$ { > access_log off; > expires max; > add_header Cache-Control public; > } > > > what I get using curl: > HTTP/1.1 200 OK > Date: Tue, 06 Oct 2009 02:12:27 GMT > Content-Type: image/gif > Content-Length: 96 > Last-Modified: Thu, 17 Sep 2009 01:51:06 GMT > Connection: close > Vary: Accept-Encoding > Expires: Thu, 31 Dec 2037 23:55:55 GMT > Cache-Control: max-age=315360000 > Cache-Control: public > Accept-Ranges: bytes 
    Multiple Cache-Control lines are perfectly valid per RFC2616, it
    shouldn't cause any problems.
    
    If you really want them to be in single line, just set everything
    in add_header instead of using "expires max" to set
    Cache-Control: max-age and Expires.  E.g.
    
     add_header Expires "Thu, 31 Dec 2037 23:55:55 GMT"; add_header Cache-Control "public, max-age=315360000";
    
    Maxim Dounin
  • 相关阅读:
    0918作业-----所有数值未做合法性检测
    尝试安装和配置JDK,并给出安装、配置JDK的步骤
    java为什么可以跨平台执行
    字符集
    java 入门及简介
    时间轴特效
    javascript简介
    javascript while循环
    Javascript for循环
    函数豹子问题
  • 原文地址:https://www.cnblogs.com/devops/p/3038890.html
Copyright © 2011-2022 走看看