› NGINX
› NGINX Trac
› 3rd Party Modules
› Security Advisories
› CHANGES
› OpenResty
› ngx_lua
› Tengine
在线学习资源
› NGINX 开发从入门到精通
NGINX Modules
› ngx_echo
baskice
V2EX  ›  NGINX

nginx 的客户端缓存到底应该怎么写?

  •  
  •   baskice · Apr 22, 2014 · 4568 views
    This topic created in 4587 days ago, the information mentioned may be changed or developed.
    我希望实现

    1. 域名.org/ 重定向到 域名.org/Mainpage 客户端缓存无限时间 max age= max
    2. 其他页面刷新后询问服务器是否有改变,没变返回304

    网上找到的大多数都是.js .css .jpg .html这些文件如何设置缓存时间,没人关心网页缓存吗??
    7 replies  •  1970-01-01 08:00:00 +08:00
    lichao
    lichao
    Apr 22, 2014
    1
    网页内容往往都是动态的,需要避免缓存才对吧
    Livid
    Livid
    MOD
    PRO
    Apr 22, 2014
    2
    你可以把你目前的配置文件贴一下。

    反代后端和直接服务静态时的写法不完全一样。
    iCodex
    iCodex
    Apr 22, 2014
    3
    针对第一点,不管是反代还是直接服务的,都可以直接加add_header去指定。
    对于第二点,还要引入etags支持,但你也要让客户端能包含“If-None-Match”这个头,不然也没法对比是否有改变。
    xoxo
    xoxo
    Apr 22, 2014❤️1
    4
    @iCodex 是ETag谢谢
    plprapper
    plprapper
    Apr 22, 2014
    5
    静态文件的路径或者参数带时间戳 依靠这个的变化来更新。

    至于cache到啥时候看心情了吧。
    wdlth
    wdlth
    Apr 22, 2014
    6
    我是Cache-Control、Expires、ETag一起用。
    leoYu
    leoYu
    Apr 23, 2014
    7
    目前我们这里把,页面做的是pageCache,放memcache中,当然不够好
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   955 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 48ms · UTC 22:21 · PVG 06:21 · LAX 14:21 · JFK 17:21
    ♥ Do have faith in what you're doing.