浏览代码

adding caching for static ressources

Medowar 1 月之前
父节点
当前提交
1e53c247f2
共有 1 个文件被更改,包括 17 次插入 和 0 次删除
  1. 17 0
      .htaccess

+ 17 - 0
.htaccess

@@ -10,6 +10,23 @@ DirectoryIndex index.php
     RewriteRule ^(app|config|data|docs)/ - [F,L]
 </IfModule>
 
+# Cache static assets
+<IfModule mod_expires.c>
+    ExpiresActive On
+
+    # CSS and JavaScript - 1 week
+    ExpiresByType text/css "access plus 1 week"
+    ExpiresByType application/javascript "access plus 1 week"
+    ExpiresByType text/javascript "access plus 1 week"
+
+    # Images - 4 weeks
+    ExpiresByType image/jpeg "access plus 4 weeks"
+    ExpiresByType image/gif "access plus 4 weeks"
+    ExpiresByType image/png "access plus 4 weeks"
+    ExpiresByType image/webp "access plus 4 weeks"
+    ExpiresByType image/svg+xml "access plus 4 weeks"
+</IfModule>
+
 # Never serve dotfiles (.htaccess, .git*, …), flat-file data, docs, config
 # templates or lock files as plain text — regardless of directory.
 <FilesMatch "(^\.ht|^\.git|\.(?:json|md|lock|buf)$|\.sample\.php$)">