The Avatar is specified based on the url. after the avatar is changed, the url remains unchanged, that is, the url of the image is not changed, but the image has been changed because the url is not changed, so the browser still uses the original image, how can I display new images in time after the changes? Is it because of browser cache? how can I use php to understand the browser... the Avatar is specified based on the url. after the avatar is changed, the url remains unchanged, that is, the url of the image is not changed, but the image has been changed.
Because the url hasn't changed, the browser still uses the original image. how can I display the new image in time after the change? Is it because of browser cache? how can I use php to clearly understand browser cache?
Reply content:
The Avatar is specified based on the url. after the avatar is changed, the url remains unchanged, that is, the url of the image is not changed, but the image has been changed.
Because the url hasn't changed, the browser still uses the original image. how can I display the new image in time after the change? Is it because of browser cache? how can I use php to clearly understand browser cache?
Http: // yourdomain/paht/to/you/image.jpg? V = 201310100934
PHP runs in the server language and cannot manage the user's computer. For browser caching and security considerations, clear cache operations can only be handed over to users, and cannot be directly completed using JS.
So let the browser send a new request when there is a cache, as 1L said, add the query after the image. because the SRC address has changed, the browser will retrieve it again.
If CDN has a cache, you can only change the file name to ensure that the user obtains the latest file.
I don't know if you have stored images on the resource. if you have a source image, you can generate a host string to name the source image.
If the host name must be fixed, the host character can be generated in the same way as the host character stored in the resource, and then added after the screenshot, the value will use the generated host character.
The browser determines whether to cache resources and the cache duration based on the cache header in the server response. In other words, the server returns the corresponding header to tell the browser that the cached resources need to be updated.