简体   繁体   中英

HTTP Caching - Asset not serving from browser cache after setting Cache-Control Header

Initial Request 初始请求 Second Request 第二个请求 I am using a node module(express-cache-ctrl) to enable caching on aa proxy .

app.use(cache.public(3600));

My static assets have a Cache-control header on them with max-age . I am unable to figure out why they reload on a refresh and not served from browser-cache .

Edit : `

var onProxyRes = function(proxyRes, req, res) {
    if ( proxyRes.headers["content-type"] == "text/css" || 
    proxyRes.headers["content-type"] == "application/javascript") {
    proxyRes.headers["Cache-Control"] = "public, max-age=86400";
  }

//add something here to modify proxy response };` Tried manually adding caching header on proxy response also doesn't cache assets

Found this in a Chrome forum , while running a https server if you have any kind of SSL error then in that case browser prevents caching over HTTPS https://bugs.chromium.org/p/chromium/issues/detail?id=110649 . Works for me now

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM