We can clear the CSS style sheet cache by using the query selector like this:
<link rel="stylesheet" type="text/css" href="stylesheet.css?v=1.0" />
Whenever we change the style sheet and need the browsers to be cleared about our CSS style sheet, we could change the version number like 1.1, 1.2, etc.
Is there anything something like this for clearing HTML data?
I was having the HTML markup like this:
<img src="picturename.jpg" /><!--picture of a **man**--->
Later I need to change the picture but the same file name:
<img src="picturename.jpg" /><!--picture of a **woman**--->
I deleted the picture of man and uploaded picture of woman. But when I viewed in the browser it is showing the cached picture that is picture of a man even after very clean refresh (Ctrl+F5) and also clearing with the settings that the browsers have.
Update
I came to know every time clearing the cache is not good idea so I wanted to implement this by jquery with the following concept:
- First set the image src from
picturename.jpg
topicturename.jpg?v=1
- Store the number in local storage or in cookie. But I'm confusing to use cookie as if the user deletes the cookies then the stored variable would also be deleted thus storing it in local storage would be better idea.
- Retrieve the local storage variable number and check if the global variable number is exceeded then only change the picture src number something like this:
var cnum = 1; // author will change this number when needed
$(document).ready(function(){
var ccnum; // store in local storage then increase the number if cnum is greater than ccnum
//now change the src as of image
I need to change the src of all of my gallery images $('#mygallery img')
and actually I've hundreds of images which are to be changed after some time but needed the same file name.
How could I do?