1

Hope you're doing well.

I've tried looking for similar questions on here and on google in general, but I couldn't find an answer to my question.

I'm fairly new to developing, and I'm currently developing a website for my first client. I'm using InMotion as my hosting service, and have set-up GitHub actions to automatically update the files on the server whenever I push new commits to the repo. The website gets updated just fine whenever I push any new commits, but the problem is that I have to hard reset the cache (Shift + F5) for some changes to take effect and show up, it appears to mostly happen with CSS changes, and I'm yet to catch the same issue with JavaScript changes.

I didn't have these issues when I was hosting this previously on netlify's free hosting service as a test, so I'm guessing there's something I need to do, that InMotion doesn't automatically do from their end?

This is obviously not ideal, as so many users are not aware of hard cache resets, and wouldn't have a reason to even think about doing it, as for all they know, this is how the website looks.

I found this question on StackOverflow, but it was asked 14 years ago, and I struggled to find a concrete answer.

Is there any JavaScript code I can use, to force the user's browser to clear or update the cache, upon them loading the website?

Any help is appreciated, and thank you in advance for taking the time to read this!

coolAppl3
  • 11
  • 3
  • Just to add to this, I realise that caching is important, and shouldn't be tampered with carelessly, and ideally, I'm hoping to find a solution that merely updates the cache, rather than rewriting it. – coolAppl3 Oct 19 '22 at 01:10
  • 1
    There are ways to do this with cache control headers, and a simpler way that involves updating the names of your JS and CSS assets, or making sure that your pages import them via URLs that include nonce parameters (like "?_=") so that the browser will bypass the cache. – Pointy Oct 19 '22 at 01:44
  • @Pointy So far, this is the only solution I've managed to find/wrap my head around. It's not ideal, but it gets the job done I guess. Really appreciate the help though! – coolAppl3 Oct 19 '22 at 01:59

0 Answers0