Clear browser cache using PHP?
Question by Guest | 2012-08-19 at 20:23
I want to delete the browser's cache of my visitors with the help of PHP. Some files that were valid for a while, have now been replaced by me and I therefore, I would like to achieve, that those files cannot be loaded from the cache of my visitors any longer.
Is there any PHP script that you can recommend?
Related Topics
Reload Images, CSS, JS and Web Pages despite Browser Cache
Tip | 2 Comments
Website Performance: Caching and Expires Header for Images, CSS and JavaScript
Tutorial | 0 Comments
PHP: File Download Script
Tutorial | 0 Comments
jQuery: Detect Browser (Browser Switch)
Info | 2 Comments
PHP: Current Date and Time
Tutorial | 0 Comments
HTML Form: Redirection depending on Radiobutton or Checkbox State
Tutorial | 0 Comments
PHP: Upload of large Files
Tutorial | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
I have to disappoint you in your project, unfortunately. With PHP, you can not affect the browser cache of your visitors.
Once stored on the computer, unfortunately, you have never again access to this data. If the browser would let you do something like that, you could just delete the whole hard drive of your visitors super easy!
Only if you are using plugins like ActiveX or likewise, you can do such things, but everyone has disabled those plugins and it also makes not a good impression, if someone is surfing on your website and the virus scanner says, that the page would like to delete some files from your hard drive.
2012-08-20 at 15:55
No true. Still works.
ISPs can bypass though. But the browser rules prevents browsers from caching the page and would call a whole fresh page again when access is made. Sometimes important for dynamic website applications and still used.
2018-09-22 at 11:54
If your files are often changing, in your place, I would simply send the following header with PHP along with them:
You can add these lines just before the first issue of your PHP script into your pages. With this, you tell the browser, that it should not cache the page and it should request the contents every time again.
For pictures, you can write the following line into your HTACCESS:
What files and which file types should be affected closely, you can of course customize individually. So you can, for example, create a folder for all the images that are changing often and another folder for all the other images, that do not and could be cached without problems.
2012-08-21 at 19:16
Here's a small addition on this subject from me:
Reload pictures and websites despite cache
Last update on 2023-01-13 | Created on 2012-08-23