---
title: "apache配置expires_module缓存静态文件"
author: "小马迷途"
date: "2011-11-18T11:09:50Z"
tags: []
categories: ["开源软件"]
slug: "apache-expires-module"
draft: false
lastmod: "2011-11-18T11:09:50Z"
id: 1265398
url: "https://maxeric2007.iteye.com/blog/1265398"
---

Apache版本apache_2.2.14-win32-x86-openssl-0.9.8k.msi

修改httpd.conf文件：
1，去掉#LoadModule expires_module modules/mod_expires.so这行前面的#号

2，增加如下配置

```httpd.conf

<IfModule expires_module>
  ExpiresActive On
  ExpiresDefault "access plus 2 days"
  ExpiresByType application/x-shockwave-flash "access plus 3 days"
</IfModule>

```


restart apache服务器就生效了
通过httpwatch观察http请求Headers Received：
Expires已经是两天后了


```Headers Received

(Status-Line)	HTTP/1.1 200 OK
Accept-Ranges	bytes
Cache-Control	max-age=172800
Connection	Keep-Alive
Content-Length	561276
Content-Type	image/jpeg
Date	Fri, 18 Nov 2011 02:18:18 GMT
ETag	"2000000010a90-8907c-46ea3c3de04ac"
Expires	Sun, 20 Nov 2011 02:18:18 GMT
Keep-Alive	timeout=5, max=99
Last-Modified	Tue, 14 Jul 2009 05:32:31 GMT
Server	Apache/2.2.14 (Win32)

```