ignore caching on a given page . php

Asked

Viewed 407 times

-1

am with a php code where I get a link . so q this link expires about 10 times a day, my code checks if the link expires and brings a new one.

//o arquivo é single.php wordpress
<video id="player" poster="<?php echo $thumb; ?>" controls style="width: 100%; height: 400px;">
<source src="<?php echo $mp4;?>" type="video/mp4" />
</video>

the variable that stores the url is $mp4 , it always brings the correct link

only that for many people who visit the site appears the expired link, because of the cache.

how to make this page or code snippet is not cached in any way?

detail. am using a cache plugin for wordpress and cloudflare .

hugs

  • Put part of the code to facilitate understanding of your problem

  • edited in the right place now... hehe

1 answer

-1

In a short version:

Using PHP:

header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: 0"); // Proxies.

Using HTML:

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />

This will tell the browser to always renew the cache. So "never" has cache saved to the page.

Original response in: https://stackoverflow.com/questions/49547/how-to-control-web-page-caching-across-all-browsers

  • thanks for the reply, but I’ve tried that and it didn’t work, would something on htaccess be more appropriate? i am using a plugin for wordpress cache and cloudflare.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.