0

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

7
  • It seems you are using Chrome DevTool's Network panel. By default, the checkbox before "Disable cache" is checked. Have you de-select it? Commented Sep 13, 2017 at 12:14
  • @shaochuancs Disable cache has not been selected Commented Sep 13, 2017 at 12:17
  • It's weird. If cache is not disabled by DevTool, there is nothing wrong according to your screenshot. Commented Sep 13, 2017 at 12:26
  • @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 Commented Sep 13, 2017 at 12:34
  • Maybe you can set Cache-Control header at the original server and try again? Commented Sep 13, 2017 at 12:36

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.