How to clear the browser cache

Source: Internet
Author: User
Tags clear browser cache
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.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.