Disable Browser Cache in PHP or JavaScript in a Flash Application

How could I disable caching, for specific php files?

I found out the issue. I completely overlooked/forgot, I had the below Caching Code in the .htaccess file. School Boy error!

Once I removed the below code, the Basket Caching Problem was resolved.

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##

Should I discover a way to cache a website, without the Basket being Cached, I will add it to this answer.

How to clear browser cache with php?

header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Content-Type: application/xml; charset=utf-8");

How to prevent a browser from caching videos?

The problem is that when i erase one and upload another video, the first video stays in cache and get's displayed instead of the second one.

You should assign a new filename when the video is replaced. Generate and store a random filename (or a MD5/SHA1 hash of the file's contents, perhaps) when a video is uploaded, rather than overwriting the same file location.

Alternatively, store the date/time the video is changed, and add that as a query string parameter on the video's URL, like video.mp4?time=1481754713, which the browser will see as a separate URL for caching purposes.

How do i can disable cache in /wp-admin/*

I'm afraid that any cache headers set in .htaccess have priority, and it is impossible to override them in PHP.

The only solution that I can think of is to disable the caching setup in the .htaccess and manually set the headers in each file. It's a pain, I know, but it's all that I can fathom.

The below answer will set caching to the browser default, which I assume is not what you intend.



Related Topics



Leave a reply



Submit