Using PHP makes it very simple, you can create a versioning variable and call it in the query string of the files.
For example:
- Create a variable in a config.php file:
<?php
define(“Version”, “1”);
?>
- Apply the variable in the query strings of the file call
<link rel=”stylesheet” href=”/style.css?v=<?php echo Version; ?>” type=”text/css” />
<script type=”text/javascript” src=”/javascript.js?v=<?php echo Version; ?>“></script>
This way whenever changing this variable the browser will recognize that it is a new file and will not give the problem with the cache.
If you do not want, for some reason, to work with this form of versioning, you can also oblige the browser to always download the files at each access:
<link rel=”stylesheet” href=”/style.css?<?php echo time(); ?>” type=”text/css” />
<script type=”text/javascript” src=”/javascript.js?<?php echo time(); ?>“></script>
But this approach can hinder a little the loading of the site if the files are heavy and disturb the user experience that access frequently, by having this delay to download all the files always to display a page that he had already entered.
You work with PHP or only pure HTML and JS?
– Lucas Ayrosa
Work with PHP tbm amigo @Lucasayrosa
– user169113
Linked: What makes cache invalidation a difficult solution?
– Woss