简体   繁体   English

如何为网站中的index.html页面配置最佳缓存策略?

[英]How do I configure optimal cache policy for index.html page in my site?

I have a web site with an index.html homepage that is updated from time to time. 我有一个带有index.html主页的网站,该网站会不时更新。 We sometimes add offers for our clients, special messages and so on, which have to be visible by next day for everyone. 有时,我们会为客户添加优惠,特殊消息等,第二天所有人都必须看到这些信息。

If index.html is cached by browsers, many users will not notice that anything has changed, unless they explicitly refresh the contents of the page... 如果浏览器缓存了index.html,那么许多用户将不会注意到任何更改,除非他们明确刷新页面的内容...

Which is the best way to be sure that 100% visitors have an up-to-date index.html page, without compromising cache performance? 最好的方法是在不影响缓存性能的情况下确保100%的访问者拥有最新的index.html页面?

My best answer would be to skip out on updating the index.html each time and go with a server-side programming language, like PHP. 我最好的答案是每次都跳过更新index.html的操作,而选择像PHP这样的服务器端编程语言。 You can then set the headers for the page to not cache, and you can also set up an admin page that you can use to change the content. 然后,您可以将页面的标题设置为不缓存,也可以设置可用于更改内容的管理页面。 Or you could go with a browser-side script with JavaScript using AJAX. 或者,您可以使用使用AJAX的JavaScript浏览器脚本。 Then the page has an ability to update before the next loading of the site. 然后,页面可以在下一次加载网站之前进行更新。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 index.html 重定向到 Wordpress 站点? - How do I redirect index.html to a Wordpress site? 对于使用cloudfront在S3上托管的静态站点,如何使index.html的缓存无效? - How do you invalidate cache of index.html for a static site hosted on S3 with cloudfront? 如何链接回index.html上的选项卡? - How do I link back to a tab on my index.html? 如何为index.html添加分页? - How do I add pagination to my index.html ? 如何使网站正常工作,以使“index.html”不会出现在网站名称之后的主页链接上? - How do I make a website work so that "index.html" does not appear on my home page's link after the website name? 如何将我的index.html页面的href ID捕获到我的views.py文件中,并使用它在Django中呈现我的第二个html页面 - How do I capture the href id of my index.html page into my views.py file and use it to render my 2nd html page in Django 如何将我的index.html与我在github上的其他.html文件放在同一文件夹中? - How do I put my index.html in the same folder as my other .html files on github? 如何在 TextEdit/Mac 的 Index.html 上添加我的 html 代码。 我在 index.html 中的内容不允许我进行任何编辑 - How can I add my html code on my Index.html in my TextEdit/ Mac. My content in the index.html doesn't allow me to do any editing 如何从我的index.html文件调用jsp页面? - how to invoke jsp page from my index.html file? 当AngularJS网站内容发生变化时,如何使index.html不缓存? - How to make index.html not to cache when the site contents are changes in AngularJS website?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM