Skip to content
PHP Logo

How can PHP developers ensure that web pages are reloaded after source code updates?

PHP developers can ensure that web pages are reloaded after source code updates by adding a version parameter to the URL of their static assets (CSS, JavaScript files, images, etc.). This parameter can be a timestamp or a version number that is updated whenever the source code changes. By doing this, browsers will recognize the updated URL and reload the static assets, ensuring that users see the latest changes on the web page.

php
<link rel="stylesheet" type="text/css" href="styles.css?v=<?php echo filemtime('styles.css'); ?>">
<script src="script.js?v=<?php echo filemtime('script.js'); ?>"></script>