缓存静态HTML网站 [英] Caching Static HTML Site

查看:173
本文介绍了缓存静态HTML网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常使用WordPress,但只是完成了一个客户端项目,该项目是一个静态HTML页面,每页由8页和2个图像组成。使用WordPress我会使用w3总cachce,cloudflare,photon或通过wp引擎的解决方案。

我一直在做研究,并找到了一些关于meta标签和操作.htaccess文件的解决方案。我读过的元标签路由不是一个合理的解决方案,因为它不能用HTML5进行正确验证。 (这是指没有设置缓存,但同样的想法)

 < meta http-equiv =cache-control content =max-age = 0/> 
< meta http-equiv =cache-controlcontent =no-cache/>
< meta http-equiv =expirescontent =0/>
< meta http-equiv =expirescontent =Tue,01 Jan 01 1:00:00 GMT/>
< meta http-equiv =pragmacontent =no-cache/>

参考: 使用< meta>标签关闭所有浏览器中的缓存?



我也在这里读了一点:$ b​​ $ b http://www.metatags.info/meta_http_equiv_cache_control



使用某些东西像这样:

 < meta http-equiv =Cache-controlcontent =public> 
< meta http-equiv =Cache-controlcontent =private>
< meta http-equiv =Cache-controlcontent =no-cache>
< meta http-equiv =Cache-controlcontent =no-store>

但我不确定他们是如何工作的,哪一个是正确的。有人能指引我朝着正确的方向吗?感谢!

解决方案

离开< meta> 标签。大多数情况下,Web服务器发送的默认缓存头已经适用于静态网站。除非你有一些不寻常的要求 - 在这里看起来并不是这样 - 不应该修改它们。


I generally work with WordPress but just completed a project for a client that was a static HTML page consisting of 8 pages and ~2 images per page. Working with WordPress I would either use w3 total cachce, cloudflare, photon or a solution through wp engine.

I've been doing research and found a few solutions regarding meta tags, and manipulating an .htaccess file. The meta tag route, I read, is not a reasonable solution as it does not validate properly with HTML5. (this was specifically referring to setting up no cache, but same idea)

<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />   

Reference here: Using <meta> tags to turn off caching in all browsers?

I also read a little bit here: http://www.metatags.info/meta_http_equiv_cache_control

Using something like this:

<meta http-equiv="Cache-control" content="public">
<meta http-equiv="Cache-control" content="private">
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Cache-control" content="no-store">

But I'm not sure how they actually work and which is the correct one. Can someone point me in the right direction? Thanks!

解决方案

Step away from the <meta> tags. Default caching headers sent by the web server are, in most cases, already appropriate for a static web site. Unless you have some unusual requirements - which does not appear to be the case here - there should be no need to modify them.

这篇关于缓存静态HTML网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆