I want to disable the chrome browser cache and always communicate with the server.

Asked 1 years ago, Updated 1 years ago, 111 views

I want to disable the cache when using the chrome browser and always communicate with the server.

"I would like to use ""cache-control"" on the program to control the cache with the source code below."

response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate, max-age=0");
response.setHeader("Pragma", "no-cache");

As a result, it did not succeed.
Could you tell me if this method is wrong or if there is another method?

http google-chrome

2022-09-30 19:56

1 Answers

If you want to disable the cache, set Cache-Control to no-store.
I don't think it's good to specify more than one, such as no-cache, no-store, must-revalidate, max-age=0.

Google Web Fundamentals's HTTP Cache page explains:

nono-cache は indicates that in order to use the previously returned response as a response to subsequent requests for the same URL, you must first contact the server to see if there has been any change in the response.Therefore, if you have the appropriate validation token (ETag), specifying no-cache will cause a round trip to validate the cached response, but you can skip the download if there is no change in the response.

On the other hand, "no-store" is simpler.Regardless of the version of the response returned, the browser cache or all intermediate caches cannot store any of the responses.For example, a response that contains personal confidential or bank data.Each time a user requests this asset, a request is sent to the server and a full response is downloaded each time.

(Additional) Reference
The on-screen input data remains because of the form's auto-complete function.For more information, see To disable auto-complete form

in MDN.


2022-09-30 19:56

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.