Answer the question
In order to leave comments, you need to log in
Why is the server more important than the browser in terms of caching (or what does this server allow itself)?
I'm not a very experienced person - 1 year of work as a PHP developer.
I have the following problem.
I am developing a functionality like adding products to the cart.
And when adding a new product, the cart is in no hurry to show it (although the cookies with the new cart content seem to be perfectly overwritten) - it shows the old cart content.
Obviously, the browser, dog, takes the basket from the history, from the cache.
I began to deal with it in different ways.
I came across here, on Habré, exactly the same story:
https://qna.habr.com/q/979783
And the solution turned out to be exactly the same.
In htaccess, in which it was already written:
<IfModule mod_headers.c>
Header append Cache-Control "no-store, no-cache, must-revalidate"
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On ExpiresDefault "now"
</IfModule>
<IfModule mod_headers.c>
Header set Cache-Control "no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires 0
</IfModule>
<meta http-equiv="Cache-Control" content="no-store">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
Answer the question
In order to leave comments, you need to log in
As far as I understand, caching occurs when sending an ajax request. Therefore, you need to indicate that the request does not need to be cached in the ajax request. For example, in axios it goes something like this:
axios.get(
'https://YOUR-URL.com',
{
// query URL without using browser cache
headers: {
'Cache-Control': 'no-cache',
'Pragma': 'no-cache',
'Expires': '0',
},
}
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question