---
title: "Apache2.2缓存配置"
author: "zior"
date: "2009-09-28T11:33:02Z"
tags: []
slug: "apache2-2"
draft: false
lastmod: "2009-10-12T21:17:08Z"
id: 479213
url: "https://zior.iteye.com/blog/479213"
---

参见原文 [http://zior.org/archives/172.html](http://zior.org/archives/172.html)

#mod_expires可以减少10%左右的重复请求，让重复的用户对指定的页面请求结果都CACHE在本地，根本不向服务器发出请求。
LoadModule expires_module modules/mod_expires.so

ExpiresActive on
ExpiresByType image/gif “access plus 1 month”
ExpiresByType text/css “now plus 1 month”
ExpiresDefault “now plus 1 day”

LoadModule cache_module modules/mod_cache.so

LoadModule disk_cache_module modules/mod_disk_cache.so

CacheRoot /
CacheSize 256
CacheEnable disk /
CacheDirLevels 5
CacheDirLength 3

LoadModule mem_cache_module modules/mod_mem_cache.so

CacheEnable mem /
MCacheSize 4096
MCacheMaxObjectCount 100
MCacheMinObjectSize 1
MCacheMaxObjectSize 2048

#CacheForceCompletion 60
CacheDefaultExpire 3600
CacheMaxExpire 86400
#CacheLastModifiedFactor 0.1

mod_cache：
CacheEnable: 启动 mod_cache，其后接两个参数。第一个参数指定快取的种类，应设为 mem (记忆体快取) 或 disk (磁碟快取) 之其一；第二个参数指定使用快取的 URI 路径，如果对整个网站 (或虚拟主机) 进行快取，简单指定为根目录(/) 即可。
CacheForceCompletion: 这个值指定当 HTTP request 被取消时，内容的产生动作要完成的百分比；预设是 60(%)。
CacheDefaultExpire: 指定快取的预设过期秒数；预设值是一小时 (3600)。
CacheMaxExpire: 指定快取最大的过期秒数；预设值是一天 (86400)。
CacheLastModifiedFactor: 用来从回应里 Last Modified 资讯算出 expire date。
计算方式是：
expire period (过期时距) = 最后更新后至今的时间间距 * CacheLastModifiedFactor
而
expire date = 目前时间 + expire period
不过无论如何，过期时间不能超过 CacheMaxExpire 的设定值。
现在。如果用squid对该服务器进行反向代理的话，就可以通过cache 实现web的加速了