Set custom period of caching for server static assets (Brotli)

Discussion regarding Joomla! 5.x Performance issues.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Post Reply
User avatar
Sulpher
Joomla! Explorer
Joomla! Explorer
Posts: 307
Joined: Mon May 21, 2007 8:54 am
Contact:

Set custom period of caching for server static assets (Brotli)

Post by Sulpher » Mon Apr 29, 2024 7:02 pm

Hello,

I am using the following rules to cache static files in .htaccess:

Code: Select all

AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript

  ExpiresActive on
  ExpiresDefault                          "access plus 1 month"

  ExpiresByType text/cache-manifest       "access plus 0 seconds"

  <FilesMatch \.(html|xhtml|xml|shtml|phtml|php|txt)$>
    ExpiresDefault "access plus 0 seconds"
  </FilesMatch>
  ExpiresByType text/html                 "access plus 0 seconds"

  ExpiresByType text/xml                  "access plus 0 seconds"
  ExpiresByType application/xml           "access plus 0 seconds"
  ExpiresByType application/json          "access plus 0 seconds"

  ExpiresByType application/rss+xml       "access plus 1 hour"
  ExpiresByType application/atom+xml      "access plus 1 hour"

  <FilesMatch \.(ico)$>
    ExpiresDefault "access plus 1 week"
  </FilesMatch>
  ExpiresByType image/x-icon              "access plus 1 week"

  <FilesMatch \.(gif|png|jpg|jpeg|webp|avif|ogg|mp4|mkv|flv|swf|wmv|asf|asx|wma|wax|wmx|wm)$>
    ExpiresDefault "access plus 1 year"
  </FilesMatch>
  ExpiresByType image/gif                 "access plus 365 days"
  ExpiresByType image/png                 "access plus 365 days"
  ExpiresByType image/jpeg                "access plus 365 days"
  ExpiresByType video/ogg                 "access plus 365 days"
  ExpiresByType audio/ogg                 "access plus 365 days"
  ExpiresByType video/mp4                 "access plus 2 month"
  ExpiresByType video/webm                "access plus 2 month"

  ExpiresByType text/x-component          "access plus 2 month"

  <FilesMatch \.(eot|ttf|otf|svg|woff|woff2)$>
    ExpiresDefault "access plus 1 year"
  </FilesMatch>
  ExpiresByType application/x-font-ttf    "access plus 6 month"
  ExpiresByType font/opentype             "access plus 6 month"
  ExpiresByType application/x-font-woff   "access plus 6 month"
  ExpiresByType application/x-font-woff2  "access plus 6 month"
  ExpiresByType image/svg+xml             "access plus 6 month"
  ExpiresByType application/vnd.ms-fontobject "access plus 2 month"

  <FilesMatch \.(css|js)$>
    ExpiresDefault "access plus 1 year"
  </FilesMatch>
  ExpiresByType text/css                  "access plus 365 days"
  ExpiresByType application/javascript    "access plus 365 days"

  <FilesMatch \.(swf|pdf|doc|rtf|xls|ppt)$>
    ExpiresDefault "access plus 1 year"
  </FilesMatch>
  ExpiresByType application/x-shockwave-flash "access plus 1 year"
  ExpiresByType application/pdf               "access plus 1 year"
  ExpiresByType application/msword            "access plus 1 year"
  ExpiresByType application/rtf               "access plus 1 year"
  ExpiresByType application/vnd.ms-excel      "access plus 1 year"
  ExpiresByType application/vnd.ms-powerpoint "access plus 1 year"
All works fine except files that were pre-compressed on the server (Brotli):

Image


Could anyone advice which rules should be added to .htaccess to override period for such files from 30 days to 365 days?

I am using Brotli.

Thanks.
Joomla! extensions & e-commerce pluginshttps://norrnext.com

Joomla channel (Telegram) - @joomlahub
Follow me on X (Twitter) | LinkedIn

Post Reply

Return to “Performance - Joomla! 5.x”