苗火 Nicholas
[PHP]How to enable mod_expires&mod_headers in order to achive static cache
2019-4-10 萧


First: Open this line.



LoadModule expires_module modules/mod_expires.so





Second: Add this segment.



<IfModule mod_expires.c>

    ExpiresActive On

    ExpiresByType text/html "now plus 5 minutes"

    ExpiresByType text/css "now plus 2 months"

    ExpiresByType text/js "now plus 2 days"

    ExpiresByType image/gif "now plus 1 years"   

    ExpiresByType image/jpeg "access plus 1 years"

    ExpiresByType image/bmp "access plus 1 years"

    ExpiresByType image/x-icon "access plus 1 years"

    ExpiresByType image/png "access plus 1 years"

</IfModule>





Third: Reboot apache.





ExpiresDefault command:



ExpiresDefault "<base> [plus] {<num> <type>}*"

"base" can be set as access, now, modification.

"plus" is keywords of the command.

"num" stands for value.

"type" can be set as years, months, weeks, days, hours, minutes, seconds.

发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容