33 lines
950 B
ApacheConf
33 lines
950 B
ApacheConf
|
|
# 缓存控制配置(Apache服务器)
|
|||
|
|
|
|||
|
|
# 禁用 HTML 文件的缓存
|
|||
|
|
<FilesMatch "\.(html|htm)$">
|
|||
|
|
FileETag None
|
|||
|
|
Header unset ETag
|
|||
|
|
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
|
|||
|
|
Header set Pragma "no-cache"
|
|||
|
|
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
|
|||
|
|
</FilesMatch>
|
|||
|
|
|
|||
|
|
# 静态资源长期缓存(带hash的文件)
|
|||
|
|
<FilesMatch "\.(js|css|png|jpg|jpeg|gif|svg|ico|woff|woff2|ttf|eot)$">
|
|||
|
|
Header set Cache-Control "max-age=31536000, public, immutable"
|
|||
|
|
</FilesMatch>
|
|||
|
|
|
|||
|
|
# 启用 Gzip 压缩
|
|||
|
|
<IfModule mod_deflate.c>
|
|||
|
|
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/json application/xml
|
|||
|
|
</IfModule>
|
|||
|
|
|
|||
|
|
# SPA 路由支持
|
|||
|
|
<IfModule mod_rewrite.c>
|
|||
|
|
RewriteEngine On
|
|||
|
|
RewriteBase /
|
|||
|
|
RewriteRule ^index\.html$ - [L]
|
|||
|
|
RewriteCond %{REQUEST_FILENAME} !-f
|
|||
|
|
RewriteCond %{REQUEST_FILENAME} !-d
|
|||
|
|
RewriteRule . /index.html [L]
|
|||
|
|
</IfModule>
|
|||
|
|
|
|||
|
|
|