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 · 4350 views
    This topic created in 4476 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
        1
    lichao  
       Apr 22, 2014
    网页内容往往都是动态的,需要避免缓存才对吧
    Livid
        2
    Livid  
    MOD
    PRO
       Apr 22, 2014
    你可以把你目前的配置文件贴一下。

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

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