Core PHP, How To, PHP Beginners

How to Check Page is Refreshed in PHP

To Check Page is Refreshed in PHP, we use PHP superglobal variable. $_SERVER: Cache-control is an HTTP protocol header which specifies the...

Written by Bikash · 47 sec read >
How to Check Page is Refreshed in PHP

To Check Page is Refreshed in PHP, we use PHP superglobal variable.

How to Check Page is Refreshed in PHP
How to Check Page is Refreshed in PHP

$_SERVER['HTTP_CACHE_CONTROL']: Cache-control is an HTTP protocol header which specifies the policies of browser caching on both side, one is server-side and another is client-side.

These policies are used to check what information is cached and the maximum age of that information on the browser.

Source Code to Check Page is Refreshed in PHP

Copy and paste the complete code to the PHP file and run it, on the first run it says “This page is first time visited. Not refreshed.” and after that “This Page Is refreshed.”

Cache-Control: Max-Age

The Cache-Control: Max-Age defines the time in seconds to store the cached information on the browser side and also set the expiration time of the same.

Example:

Example of Cache-Control: Max-Age

Here is complete example and explanations How we Check Page is Refreshed in PHP.

To know more about Cache-control you check elaboration here: https://www.imperva.com/learn/performance/cache-control/

Also Check:

Happy Coding..!

Was this article helpful?
YesNo
Written by Bikash
My name is Bikash Kr. Panda. I own and operate PHPCODER.TECH. I am a web Programmer by profession and working on more than 50 projects to date. Currently I am working on the web-based project and all the CMS and frameworks which are based on PHP. Profile

One Reply to “How to Check Page is Refreshed in PHP”

Leave a Reply

Your email address will not be published. Required fields are marked *