Apache配置静态缓存
[root@Linux9 logs]# apachectl -M     #查看expires_modul模块加载

expires_module (shared)

[root@Linux9 logs]# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf

以下为静态缓存配置:

45 <IfModule mod_expires.c>
 46     ExpiresActive on
 47     ExpiresByType image/gif "access plus 1 days"
 48     ExpiresByType image/jpeg "access plus 24 hours"
 49     ExpiresByType image/png "access plus 24 hours"
 50     ExpiresByType test/css "now plus 2 hours"
 51     ExpiresByType application/x-javascripts "now plus 2 hours"
 52     ExpiresByType application/x-shockwave-flash "now plus 2 hours"
 53     ExpiresDefault "now plus 0 min"
 54 </IfModule>

[root@linux9 logs]# apachectl -t
Syntax OK

[root@linux9 logs]# apachectl graceful

注:ExpiresActive on       #缓存开关 启用或禁产生"Expires:"和"Cache-Control:"头的功能

ExpiresDefault "now plus 0 min" #默认不缓存 设置了其作用范围内的所有文档的默认有效期的计算方法

修改ExpiresByType image/png "access plus 12 hours"

[root@Linux9 apache2]# vim conf/extra/httpd-vhosts.conf
[root@Linux9 apache2]# apachectl graceful
[root@Linux9 apache2]# curl -x192.168.25.57:80 'http://www.yh.com/static/image/common/logo.png' -I
HTTP/1.1 200 OK
Date: Thu, 07 Jan 2016 03:53:06 GMT
Server: Apache/2.4.17 (Unix) PHP/5.5.9
Last-Modified: Tue, 08 Dec 2015 02:39:16 GMT
ETag: "1149-52659e1375d00"
Accept-Ranges: bytes
Content-Length: 4425
Cache-Control: max-age=43200
Expires: Thu, 07 Jan 2016 15:53:06 GMT
Content-Type: image/png

如果修改:ExpiresByType image/gif "access plus 2 days"
Cache-Control: max-age=172800   两天时间
注:now和access,hour和hours都一样用!

本文转自 boy461205160 51CTO博客,原文链接:http://blog.51cto.com/461205160/1732469

Apache静态缓存配置相关推荐

  1. thinkphp htmls.php,ThinkPHP静态缓存简单配置和使用方法详解

    本文实例讲述了ThinkPHP静态缓存简单配置和使用方法.分享给大家供大家参考,具体如下: 根据ThinkPHP官方手册:ThinkPHP内置了静态缓存类,通过静态缓存规则定义来实现了可配置的静态缓存 ...

  2. Nginx配置+转发8080端口+页面静态缓存+https配置

    +++ js刷新页面: https://www.jb51.net/article/14397.htm https证书: https://wzfou.com/letsencrypt/ Linux Ngi ...

  3. apache站点优化—静态缓存

    一.静态缓存介绍 用户每次访问网站都会将页面中的所有元素都请求一遍,全部下载后通过浏览器渲染,展示到浏览器中.但是,网站中的某些元素我们一般都是固定不变的,比如logo,框架文件等元.,用户每次访问都 ...

  4. Nginx缓存、静态文件缓存配置

    Nginx静态Server基本配置 server {listen 80; #监听的端口server_name www.test.com; #监听的域名charset utf-8;#编码root /us ...

  5. Nginx+Apache Yii2.0 配置方案

    最近用Yii2.0框架做了个小项目,虽然项目本身业务逻辑不复杂,但是由于本身业务逻辑的特殊性,在上午9点到12点之间系统访问量会突然上升(浏览量和用户上传文件量).导致系统单纯的部署在Apache下, ...

  6. Apache经常使用配置

      Apache採用IBM HTTPServer,内核为Apache/2.0.47 Server version: IBM_HTTP_Server/6.1.0.13 Apache/2.0.47   查 ...

  7. Nginx安装,Nginx静态缓存,Nginx Gzip压缩,Nginx负载均衡,Nginx方向代理,Nginx+Tomcat+Redis做session共享

    Nginx安装 nginx-1.10.1.tar.gz安装,参考http://blog.csdn.net/tototuzuoquan/article/details/47381907. 修改nginx ...

  8. php 静态扩展,thinkphp5行为扩展实现html静态缓存设置

    thinkphp5行为扩展实现html静态缓存设置 2018-06-19 11:53:10ThinkPHP thnkphp5行为扩展html静态缓存 利用钩子thinkphp钩子进行行为扩展.先上本地 ...

  9. 初次使用Apache、ip地址、防火墙、域名、DNS、hosts文件、端口、URL介绍、Apache配置文件、配置虚拟主机、请求响应、http协议、

    Apache提供web服务: 启动Apache,让其客户端可以使用你机器上安装的Apache提供的web服务,访问你机器上的网站.这种情况下你的计算机就是服务器,别人的机器就是客户端. 注意:确保配置 ...

  10. Nginx安装,Nginx静态缓存,Nginx Gzip压缩,Nginx负载均衡,Nginx方向代理,Nginx+Tomcat+Redis做session共享...

    Nginx安装 nginx-1.10.1.tar.gz安装,参考http://blog.csdn.net/tototuzuoquan/article/details/47381907. 修改nginx ...

最新文章

  1. 3指南针旋转_Qt编写自定义控件6-指南针仪表盘
  2. 冲上热搜的这款国产“阿法狗”,究竟是什么来头?
  3. 聊聊并发(一)——深入分析Volatile的实现原理
  4. Problem executing scripts APT::Update::Post-Invoke-Success ‘if /usr/bin/test -w /var/lib/command-not
  5. python 随机名言_如何用简易代码自动生成经典语录
  6. html表格按钮相对位置不变,表格中如何使td或div相对定位在某一行上面
  7. SQL初级语法 [查询: SELECT]
  8. 远程桌面服务器连接失败,Windows服务器远程桌面连接失败是什么原因
  9. 收入时间序列——之预测总结篇
  10. 什么是javaEE、javaSE、javaME,这三者区别是什么?
  11. 苹果错误分析报告preferreuserinterface_20182019年苹果产业链分析报告
  12. Wordpress搭建完毕上传主题报错,Unable to create directory wp-content/uploads/...
  13. JavaGuide--Java篇
  14. C22_OC12-protocol协议
  15. React基础(伍)———【案例】todoList
  16. 你们要的Java学习路线图,来喽
  17. 不同软件求解超导温度用的方程
  18. statement suspended, wait error to be cleared
  19. STM32--RFID无线射频技术(RC522刷卡模块)
  20. JSR303以及常见Validator实现

热门文章

  1. 未能加载文件或程序集System.EnterpriseServices
  2. 【 理想的机器学习书】
  3. 【OpenCV】分离多通道图像RGB的值
  4. 高斯滤波程序编写 opencv C++ CSU
  5. 透视形变(perspective distortion)
  6. 实现UncaughtExceptionHandler来实现获取应用全局的crash信息
  7. mysql日志打开_MySql 打开日志文件
  8. JavaEE核心API--Servlet
  9. Android 属性动画简单分析(一)
  10. 制作单机俄罗斯游戏心得(三)