The avatar is specified according to the URL, the URL is still unchanged after changing the Avatar, that is, the URL points to the picture address has not changed, but the picture has been replaced
Because the URL has not changed, so the browser or the original picture, how to change the timely display of new pictures? Is it because of the browser cache, how to use PHP clear browser cache it
Reply content:
The avatar is specified according to the URL, the URL is still unchanged after changing the Avatar, that is, the URL points to the picture address has not changed, but the picture has been replaced
Because the URL has not changed, so the browser or the original picture, how to change the timely display of new pictures? Is it because of the browser cache, how to use PHP clear browser cache it
http://yourdomain/paht/to/you/image.jpg?v=201310100934
PHP is a server-side language that is not managed by the user's computer. Browser has a cache, security considerations, clear cache operation can only be handed over to the user, can not use JS to directly complete.
So to let the browser in the case of a cache, a new request, as 1L said, after the image added to the query, because the SRC address has changed, the browser will be re-fetch.
If the CDN has a cache, it can only change the file name to ensure that the user is absolutely up-to-date.
I don't know if you have storage like the path in the library, if there is, you can generate the random string as the name of the picture.
If the image name has to be fixed, you can also generate the same random word designators stored in the library, and then Gajah Mada on the map, value is generated by the random character.
The browser determines whether to cache resources and how long to cache based on the head of the cache in the server response. That is, essentially the server returns the corresponding header to tell the browser that those cached resources need to be updated.