javascript - How To Force Reload Cached HTML Files - Stack Overflow

I have a simple website with css and html, everytime I upload new content it takes days to refresh. Is

I have a simple website with css and html, everytime I upload new content it takes days to refresh. Is there a line of code that forces the browser to reload my code? I have a pdf link which changes week to week. I don't know if to force the entire code or just force the pdf link. Thanks

I have a simple website with css and html, everytime I upload new content it takes days to refresh. Is there a line of code that forces the browser to reload my code? I have a pdf link which changes week to week. I don't know if to force the entire code or just force the pdf link. Thanks

Share Improve this question asked Jan 8, 2021 at 21:46 thehunterbatthehunterbat 611 gold badge1 silver badge4 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 2

Please check the following link: How do we control web page caching, across all browsers?

There are different ways to do that:

If you want to use a htaccess file, add the following line to it:

<IfModule mod_headers.c>
  Header set Cache-Control "no-cache, no-store, must-revalidate"
  Header set Pragma "no-cache"
  Header set Expires 0
</IfModule>

And if you want to just do that in the main html file, add the following to it within the head tag:

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">

I hope my answer helps you.

You can add parameters to your static files, like:

<script src="your-source-here.js?v=34535" />

Same goes for other files.

For more advanced solutions: How to force the browser to reload cached CSS and JavaScript files

Use CTRL + SHIFT + R to reload

What chrome does is, when you load the page, it loads the external scripts. The first time you load the scripts, it caches it, so that it won't have to load it every single time. To clear the cache, use CTRL SHIFT R

Check this out: Clear the cache in JavaScript

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744203324a4562985.html

相关推荐

  • javascript - How To Force Reload Cached HTML Files - Stack Overflow

    I have a simple website with css and html, everytime I upload new content it takes days to refresh. Is

    8天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信