# apache 配置静态元素过期时间

修改虚拟主机配置文件

```bash
vim /usr/local/apache/conf/extra/httpd-vhosts.conf
# 基于动态库mod_expires.c 保证编译时存在(service httpd -M)

<VirtualHost *:80>
    ...
    ...
    <IFModule mod_expires.c>
        ExpiresActive on #功能启动
        ExpiresByType image/gif "access plus 1 days" #gif图片，缓存1天
        ExpiresByType image/jpeg "access plus 2 days" #jpeg图，缓存2天
        ExpiresByType image/png "access plus 24 hours" #png图，缓存24小时
        ExpiresByType text/css "now plus 2 hours"
        ExpiresByType applicantion/x-javascript "now plus 2 hours"
        ExpiresByType applicantion/x-shockwave-flash "now plus 2 hours"
        ExpiresDefault "now plus 0 min"
    </IfModule>
</VirtualHost>
```

重新加载配置文件

```
# 检查配置文件
/usr/local/apache2/bin/apachectl –t
# 重新加载配置文件
/usr/local/apache2/bin/apachectl graceful
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lack.gitbook.io/operation-and-maintenance/xu-ni-hua/apache-pei-zhi-jing-tai-yuan-su-guo-qi-shi-jian.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
