0

is there a way to sent the browser, that he should cache the response/body (json) for minutes/hours/days?

I want to reduce server request and one a specific route where the content change very rarely (probably once a week). This will reduce the traffic on the client side aswell.

i've tried with:

    res.set('Cache-Control', 'public, max-age=6000');
    res.set('Expires', new Date(Date.now() + 60000).toUTCString());
    res.set('Prgama', 'cache');

but chrome ignores that, but maybe that's wrong. Im clueless and google didn't help yet.

Final result should be like (Chrome Network Tab):

  • First Client request: Status Code 200 OK
  • Second Client request: STatus Code OK (from disk cache) etc.

After the the time expires, again the Status Code 200 OK (WITHOUT from disk cache) like static files (images) works.

I only find server side caching, but this won't reduce GET requests to the Backend.

end
  • 75
  • 2
  • 7
  • I read your question over and over again, but could not understand your problem, please edit your question. – jsDevia Aug 13 '18 at 11:08
  • Have you checked out [Possible to cache JSON to increase performance / load time?](https://stackoverflow.com/q/17612962) – dbc Aug 14 '18 at 10:17

0 Answers0