[英]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.