简体   繁体   中英

Can you force a PHP include to not be cached with a page?

I have this PHP include on my website's homepage.

<?php include($_SERVER['DOCUMENT_ROOT'].'/streams/streamers.php'); ?>

I want to make it so when it pulls that PHP page, it always pulls it fresh from the server.

I have looked all over to try to see if this is possible.

Thank you for your time. It is very much appreciated.

Browser is who decides to cache your request or not.

To define if a page should be or not cached, you must use .htaccess or set that page has been modified in http headers.

PHP execute that file. It does not cache its response. The final response it can or it can not be cached by the browser. Add this line to tell the browser not to cache your page.

header("Cache-Control: no-cache, must-revalidate");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM