GitHub Pages aggressively caches static files (HTML, CSS, JS), which can sometimes prevent updates from appearing immediately. Since GitHub does not support .htaccess
for direct cache control, you must use alternative methods.
- β No, if you did not enable Jekyll when setting up GitHub Pages.
- β
Yes, if your repository contains
_config.yml
,_layouts/
,_includes/
, or_posts/
, as GitHub Pages will assume it's a Jekyll site. - π Creating a
.nojekyll
file in your repo prevents GitHub from processing files as a Jekyll site but is unnecessary for pure HTML/CSS sites.
- β‘ HTML updates instantly.
- π CSS and JavaScript can be cached longer (up to 10 minutes or more).
- π If changes donβt appear, force refresh (
Ctrl + F5
).
Since you cannot modify HTTP headers on GitHub Pages, the best way to force fresh loads is cache busting.
Modify your file URLs with a query string:
<link rel="stylesheet" href="styles.css?v=12345">
<script src="script.js?v=67890"></script>
π‘ Effect: The browser treats styles.css?v=12345
as a new file and reloads it.
Instead of modifying URLs with query strings, rename the files when making updates:
- π
styles.css
βstyles-v2.css
- π
script.js
βscript-v2.js
- π Update your HTML references accordingly.
If updates do not appear, manually force refresh:
- π₯ Windows/Linux:
Ctrl + F5
(Chrome/Edge/Firefox) - π Mac:
Cmd + Shift + R
- π DevTools: Open Developer Tools (
F12
), go to Network Tab, check "Disable Cache", then refresh.
- π GitHub caches files globallyβupdates may take up to 10 minutes to propagate.
- β³ If your changes are not appearing, wait a few minutes before testing again.
- π€ Use GitHub Actions (if applicable) to trigger automatic updates by changing version numbers.
β You do NOT need .nojekyll
unless Jekyll-related files exist.
β Use query strings (?v=12345
) or rename files to force fresh loads.
β GitHub caches static files for ~10 minutesβbe patient if changes donβt appear immediately.
β Force refresh (Ctrl + F5
) if updates are not visible.
- GitHub Pages Documentation - Official guide on configuring GitHub Pages.
- MDN Web Docs - Cache Busting - Explains cache busting techniques.
- MDN Web Docs - HTTP Caching - Detailed caching behavior in browsers.
β‘ Would you like an automated script to update version numbers dynamically? π