0
votes

Initial RequestInitial Request Second RequestSecond Request I am using a node module(express-cache-ctrl) to enable caching on a a 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

1
It seems you are using Chrome DevTool's Network panel. By default, the checkbox before "Disable cache" is checked. Have you de-select it? - shaochuancs
@shaochuancs Disable cache has not been selected - Jeson Dias
It's weird. If cache is not disabled by DevTool, there is nothing wrong according to your screenshot. - shaochuancs
@shaochuancs Btw i am setting my headers at the proxy level . i don't think that should be a problem but i am not sure now - Jeson Dias
Maybe you can set Cache-Control header at the original server and try again? - shaochuancs

1 Answers

2
votes

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