0

I'm using GitHub to host my site it worked normally for a while but after a while my browser stopped updating the CSS and JS files HTML files update normally. For others it works normally but not for me.

I have tried: CTRL+F5, CTRL+SHIFT+R, clearing cache.

Here is the source: https://github.com/Jakooob14/jakooob-site

The site: https://jakooob.ml

Jakooob
  • 35
  • 5
  • Most likely what you want is to implement some sort of "cache-busting" technique-- this is a catch-all term for methods that force the browser to fetch fresh versions of resources. [Here is a CSS Tricks article on cache busting CSS](https://css-tricks.com/strategies-for-cache-busting-css/), but I imagine most of the techniques are relatively agnostic to other forms of resources. – Alexander Nied Feb 22 '22 at 20:47
  • Also, try in an incognito window. If that doesn't work, then the issue is most likely not with your browser-- perhaps you haven't actually updated your files, or one of the servers Github uses to deliver content is misbehaving... – Alexander Nied Feb 22 '22 at 20:48

1 Answers1

2

It's cool that sites like GitHub offer free hosting, but I'm not always clear how they manage caching of files. One thing you can do is add a query string to the URL, which will force the browser to fetch a fresh copy:

<link rel="stylesheet" href="style-index.css?v=1" />

The ?v=1 above should do the trick.

Djave
  • 8,595
  • 8
  • 70
  • 124
  • This worked thank you, but I'd need to update the ```?v=1``` to ```?v=2```, ```?v=2```, ```?v=3``` and so on right? – Jakooob Feb 22 '22 at 20:53
  • 1
    Generally yes-- ideally you would integrate this into some sort of build script. Also, please remember to mark this answer as accepted if it worked for you. Good luck, and happy coding! – Alexander Nied Feb 22 '22 at 20:54
  • Ah yes thank you I will mark it as an answer I just need to wait for the cooldown thanks! – Jakooob Feb 22 '22 at 20:55
  • 2
    My strategy is to use a date string so I know when it was last updated: `?v=22.2.22`. Happy Twos Day. – isherwood Feb 22 '22 at 20:56