Answer the question
In order to leave comments, you need to log in
How to remove caching from the browser on the "back" button?
The essence of the problem:
The client opens a page with products.
Clicks "Add item to cart"-> A script is launched that sends an ajax request and changes the number of items in the block (for example, it was 2 to 3) of the basket in the site header, and marks the item as "added" (inserts a checkmark icon in the item block).
Further, if the user follows any link and presses the "Back" button, then there are 2 products in the basket again and not 3, and there is no block with a "tick". That is, the browser loaded the page cache before the js script changed.
How to fix?
Probyval:
<meta http-equiv="Cache-Control" content="no-cache"> в head
Cache-Control в htaccess
Answer the question
In order to leave comments, you need to log in
Try like this:
<input type="hidden" id="refreshed" value="no">
<script type="text/javascript">
onload=function(){
var e=document.getElementById("refreshed");
if(e.value=="no")e.value="yes";
else{e.value="no";location.reload();}
}
</script>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question