Posts Tagged: cache


24
二 10

使用expires模块降低apache负载

使用expires模块声明静态文件过期时间-减少客户端不必要的请求

<Location />
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/* “access plus 1 month”
ExpiresByType text/css “access plus 1 month”
ExpiresByType text/javascript   “access plus 1 month”
ExpiresByType application/x-javascript “access plus 1 month”
</IfModule>
</Location>
另一种方式:
<FilesMatch “\.(css|js|jpg|gif|png)$”>
<IfModule mod_expires.c>
ExpiresActive  On
ExpiresDefault A2592000
</IfModule>
</FilesMatch>

21
八 08

仍然是缓存

Last-Modified: Wed, 13 Dec 2006 06:11:14 GMT
检查这行是否每次访问都变化。如果一直变化,说明页面是动态的,并不合适squid缓存。squid在每次请求的时候都会检查这行,判断页面是否已经过期,并且对过期的页面重新获取。

Cache-Control: no-store, no-cache,must-revalidate, post-check=0, pre-check=0
这行是负责控制缓存。no-store、no-cache、must-revalidate等都是要求squid禁止缓存内容,并且在每次请求的时候都去验证页面是否过期。

Expires: Thu, 19 Nov 1981 08:52:00 GMT 过期时间如果大于当前时间,也会被认为是页面已经过期,需要重新获取。这样的页面也不会被缓存。

Pragma: no-cache 这句也是禁止缓存。


27
七 08

缓存DNS查询,解决DNS查询慢的问题

pdnsd, written by Thomas Moestl, is a proxy DNS server with permanent caching (the cache contents are written to hard disk on exit) that is designed to cope with unreachable or down DNS servers (for example in dial-in networking).
The official pdnsd homepage by the original author can be found at http://home.t-online.de/home/Moestl/, but unfortunately pdnsd is no longer being maintained by him. As far as I know I am presently the only one actively working on the code, so if you want the latest features and fixes, this is the place to get them.

主页:http://www.phys.uu.nl/~rombouts/pdnsd.html

配置起来非常简单:

1. 将example配置文件复制一份

2. 将:

server {
label= “myisp”;
ip = 58.215.76.163

IP换成自己的ISP提供的DNS地址,多个用”,”隔开

3. 最重要的一步,许多DNS不接受”ping”测试,所以要将:

uptest=if/ping 改成

uptest=query

4.  将/etc/resolv.con里的nemeserver改成127.0.0.1

PS:

pdnsd.conf是可以控制pdnsd的返回结果的,就是说,可以通过配置pdnsd来达到自定义解析结果的日的。

另外,我们使用pdnsd的根本原因是因为ISP的DNS不稳定,解析慢。pdnsd可以直接从根服务器查询开始,更不必依赖于ISP的DNS。但是需要说明的是,使用了CDN服务的站点,可以会取到不精确的地址,而导致访问速度不佳。


1
七 08

对缓存的新认识

这个是FaceBook的应用构架,没什么好说的。