Prevent browsers from caching CSS and JS files

From Logic Wiki
Revision as of 08:51, 1 October 2026 by AliIybar (Talk | contribs) (Created page with "Category:HTML Category:CSS Category:js == .htaccess == <pre> # Prevent browsers from caching CSS and JS files <IfModule mod_headers.c> <FilesMatch "\.(css|js)...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


.htaccess

# Prevent browsers from caching CSS and JS files
<IfModule mod_headers.c>
    <FilesMatch "\.(css|js)$">
        Header set Cache-Control "no-cache, no-store, must-revalidate"
        Header set Pragma "no-cache"
        Header set Expires "0"
    </FilesMatch>
</IfModule>

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css             "access plus 0 seconds"
    ExpiresByType application/javascript "access plus 0 seconds"
    ExpiresByType text/javascript      "access plus 0 seconds"

    # Keep images and PDFs cached for 7 days
    ExpiresByType image/jpeg           "access plus 7 days"
    ExpiresByType image/png            "access plus 7 days"
    ExpiresByType image/gif            "access plus 7 days"
    ExpiresByType image/webp           "access plus 7 days"
    ExpiresByType application/pdf      "access plus 7 days"
</IfModule>

head

<link type="text/css" rel="stylesheet" href="css/reset.css?v=20261001">
        <link type="text/css" rel="stylesheet" href="css/plugins.css?v=20261001">
        <link type="text/css" rel="stylesheet" href="css/style.css?v=20261001">
        <link type="text/css" rel="stylesheet" href="css/color.css?v=20261001">
        <link type="text/css" rel="stylesheet" href="css/popup1.css?v=20261001">