httpd之静态缓存
2016-06-06 07:35
423 查看
静态缓存:用户访问一个站点,大多数元素为图片、js、css,这些文件会被客户端的浏览器缓存到本地的电脑上,加快了用户体验,但有一定的时效性。方式1、mod_expires模块实现 <IFModule mod_expires.c> ExpiresActive on ExpiresByType image/gif "access plus 1 days" ExpiresByType image/jpeg "access plus 24 hours" ExpiresByType image/png "access plus 24 hours" ExpiresByType text/css "now plus 2 hour" ExpiresByType application/x-javascript "now plus 2 hours" ExpiresByType application/javascript "now plus 2 hours" ExpiresByType application/x-shockwave-flash "now plus 2 hours" ExpiresDefault "now plus 0 min" </IfModule>
方式2、mod_headers 模块实现<ifmodule mod_headers.c> # htm,html,txt 类的文件缓存一个小时 <filesmatch "\.(html|htm|txt)$"> header set cache-control "max-age=3600" </filesmatch>
# css, js, swf 类的文件缓存一个星期 <filesmatch "\.(css|js|swf)$"> header set cache-control "max-age=604800" </filesmatch>
# jpg,gif,jpeg,png,ico,flv,pdf 等文件缓存一年 <filesmatch "\.(ico|gif|jpg|jpeg|png|flv|pdf)$"> header set cache-control "max-age=29030400" </filesmatch></ifmodule>
来自为知笔记(Wiz)
方式2、mod_headers 模块实现<ifmodule mod_headers.c> # htm,html,txt 类的文件缓存一个小时 <filesmatch "\.(html|htm|txt)$"> header set cache-control "max-age=3600" </filesmatch>
# css, js, swf 类的文件缓存一个星期 <filesmatch "\.(css|js|swf)$"> header set cache-control "max-age=604800" </filesmatch>
# jpg,gif,jpeg,png,ico,flv,pdf 等文件缓存一年 <filesmatch "\.(ico|gif|jpg|jpeg|png|flv|pdf)$"> header set cache-control "max-age=29030400" </filesmatch></ifmodule>
来自为知笔记(Wiz)
相关文章推荐
- 网络demo
- httpd之使用rewrite对目录进行访问控制
- Android官方开发文档Training系列课程中文版:连接无线设备之网络服务搜索功能
- Volley网络请求框架
- http协议详解
- TCP 的那些事儿系列
- OkHttp3浅析
- 知识付费还是内容付费?网络时代的内容、体验与注意力
- Ceph心跳与网络
- IDC行业往何处去?
- Java 网络IO编程总结(BIO、NIO、AIO均含完整实例代码)
- Linux 网络 I/O 模型简介(图文)
- IDC行业往何处去?
- https对接相关
- No mapping found for HTTP request with URI [/HelloWeb/] in DispatcherServlet with name 'HelloWeb' Spring MVC
- 5.5 神经网络的正则化
- 网络七层及模型&&网络数据包
- 5.4 Hessian矩阵
- Java 网络编程之无网不欢
- iOS开发网络篇—NSURLConnection基本使用