2

I´m creating a static web page with HTML and CSS, the problem comes when I upload new info into the server. When I try to reload the page nothing changes. It only changes when I make a ctrl f5 reload. Is there a way to make the site to reload itself so the user can see the newest info every time they enter the web site?

I tried using a "?" sing ager calling the CSS file but it's not working

link href="CSS/styles.css?v=1.1" rel="stylesheet"

Zhubei Federer
  • 1,274
  • 2
  • 10
  • 27
  • Ctrl + F5 (Windows/LInux) – Zhubei Federer May 31 '19 at 06:03
  • 1
    how do you upload the files? Are you editing the cache file or the actual file you are uploading? If you are using a Filezilla, there's a chance that you are editing an old copy of your files and uploading the wrong one – MuntingInsekto May 31 '19 at 06:03
  • 2
    What you're looking to do is something called "cache busting." If you google that phrase, you will find tons of articles on how to implement cache busting. Good luck! – Stephen May 31 '19 at 06:04
  • Oscar! Try using an advice given [at this question](https://stackoverflow.com/questions/1341089/using-meta-tags-to-turn-off-caching-in-all-browsers) But do not forget to remove the code at production. – Evgeny Melnikov May 31 '19 at 07:18

2 Answers2

0

Static content is cached by the browser. If the server sends a max-age then the browser will not attempt to get a new version unless the cache is expired as per the max age.

However ctrl-F5 forces a refresh disregarding the aging parameters.

You can try setting a shorter max-age on the server, but that will cause more load as the clients will fetch resources more frequently.

sepbot
  • 116
  • 1
  • 1
  • 4
0

Most likely, your browser is caching the content of your website when you visit it. The next time you visit, it'll show the native, cached copy (unless you "hard-refresh" it eg(Ctrl + F5)).So you need "Cache Busting"

You can follow this article, it may help you.

https://css-tricks.com/strategies-for-cache-busting-css/

Thank You...

Hiren Patel
  • 1,071
  • 11
  • 34