Home » How to Check Page is Refreshed in PHP

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

Advertisement

Leave a Reply

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