[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] improve server-side caching of assets

"Victor Emanouilov \(@kroky\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6a1418fa1b43f_38197db41333@gitlab-sidekiq-low-urgency-cpu-bound-v2-d7f87744c-rf77r.mail>

Victor Emanouilov pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
404c747c by Victor Emanouilov at 2026-05-25T09:22:55+00:00
[FIX] improve server-side caching of assets
---
* [FIX] improve server-side caching of assets - public/generated vs themes/ and _custom/shared receive different levels of cache-control; utilize etags

See merge request tikiwiki/tiki!10172

- - - - -


1 changed file:

- _htaccess


Changes:

=====================================
_htaccess
=====================================
@@ -12,7 +12,7 @@
 # Option 4: Add the content of this file to your httpd.conf.
 # The last two options should be repeated when the reference _htaccess file changes (when upgrading Tiki).
 #
-# DEVELOPERS: 
+# DEVELOPERS:
 # This is the sample configuration file for Apache. Must be linked to .htaccess to be active.
 # This configuration must be kept synchronized with the configuration for other Web servers .
 # If you change any rule in this file, also review and update ./web_config for IIS (Windows server).
@@ -71,9 +71,8 @@ RedirectMatch 403 /(?:\.git|node_modules)/.*$
 #</IfModule>
 
 # -- Client Cache Method -- #
-# Google wants either Last-Modified or ETag. Using ETags will improve the YSlow scores.
-# Option 1: recommended
-FileETag none
+# ETag based on modification time and size
+FileETag MTime Size
 
 <IfModule mod_headers.c>
     # -- httpoxy mitigation -- #
@@ -97,17 +96,6 @@ FileETag none
     # Uncomment only on full HTTPS; add includeSubDomains/preload only after subdomain audit:
     # Header always setifempty Strict-Transport-Security "max-age=63072000"
 
-    # Option 2:
-    #Header unset ETag
-
-    # -- Client Cache Expiration -- #
-    # Google suggests to use Expires in favour of Cache-Control.
-    # Option 1: (recommended)
-    Header unset Cache-Control
-
-    #Option 2:
-    #Header unset Expires
-
     # -- Persistent Connections -- #
     # Allow multiple requests to be sent over the same TCP connection. Enable if you serve a lot of static content
     # but, be aware of the possible disadvantages!
@@ -138,22 +126,18 @@ FileETag none
     # -- Enable video/audio seek -- #
     Header set Accept-Ranges bytes
 
-</IfModule>
-
-# -- Expires Headers -- #
-# If the site is in active development, you may want to comment out this section.
-<IfModule mod_expires.c>
-    <FilesMatch "(?i)\.(gif|png|jpe?g|svgz?|ico)$">
-        ExpiresActive on
-        ExpiresDefault "access plus 1 month"
-    </FilesMatch>
-    <FilesMatch "(?i)\.(js|css)$">
-        ExpiresActive on
-        ExpiresDefault "access plus 1 month"
-    </FilesMatch>
-    <FilesMatch "(?i)\.(woff|woff2)$">
-        ExpiresActive on
-        ExpiresDefault "access plus 1 month"
+    # -- Cache-Control Headers -- #
+    # Vite-built assets — cache 30 days
+    <If "%{REQUEST_URI} =~ m#/public/generated/#">
+        Header set Cache-Control "public, max-age=2592000, must-revalidate"
+    </If>
+    # Theme and customization JS/CSS — short cache, always revalidate
+    <If "%{REQUEST_URI} =~ m#/(themes|_custom/shared)/.*\.(js|mjs|css)$#i">
+        Header set Cache-Control "public, max-age=3600, must-revalidate"
+    </If>
+    # Images and fonts — moderate cache
+    <FilesMatch "(?i)\.(gif|png|jpe?g|svgz?|ico|woff2?|ttf|eot|otf)$">
+        Header set Cache-Control "public, max-age=86400, must-revalidate"
     </FilesMatch>
 </IfModule>
 



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/404c747c52c48b95501ff55cdd5054887c679037

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/404c747c52c48b95501ff55cdd5054887c679037
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.