[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"

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.

标签: php


Powered by anycle 湘ICP备15001973号