When making changes to HTML or CSS, they are not visible on the page

1

When I make changes to a website that is already running, end users for the browser cache issue, do not see the changes immediately until they clear the browser cache or enter incognito mode.

There will be some solution so that when making changes in HTML or CSS these are reflected immediately upon entering the web without needing to Clean Cache, enter Incognito Mode, use the Network / Disbled Cache of google chrome (Which does not work most of the time) or install an extension to clean the cache ??

    
asked by KrmX 21.11.2018 в 17:55
source

1 answer

1

In HTML you can use the following tags in your <head> :

<meta http-equiv="Expires" content="0">

<meta http-equiv="Last-Modified" content="0">

<meta http-equiv="Cache-Control" content="no-cache, mustrevalidate">

<meta http-equiv="Pragma" content="no-cache">

In PHP you can achieve it in the following way:

<?php

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

header("Expires: Sat, 1 Jul 2000 05:00:00 GMT"); // Fecha en el pasado

?>

You can even modify your .htaccess :

## Fecha de expiracion de cache ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/png "access 1 month"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType image/jpg "access 1 month"
ExpiresByType image/jpeg "access 1 month"
ExpiresByType image/gif "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access plus 1 month"
</IfModule>
## fin cache ##

You can find information about the meta tags here , you also have this site with more details about the meta tag HTTP-EQUIV

    
answered by 21.11.2018 в 18:05