Advertisement

Htaccess cache-control does not work for JS files

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
Mr. Wimpy
Joomla! Guru
Joomla! Guru
Posts: 553
Joined: Fri Dec 02, 2005 10:46 am
Location: The Netherlands

Htaccess cache-control does not work for JS files

Post by Mr. Wimpy » Tue Sep 17, 2024 9:02 am

Maybe not 100% Joomla related, but...

The JS files are not cached.
I use the following in .htaccess

Code: Select all

<ifModule mod_headers.c>
(...)
  # CSS & JS - 1 week
  <filesMatch "\.(css|js)$">
    Header set Cache-Control "max-age=604800, public"
  </filesMatch>
</ifModule>
Oddly it does work for css files.
For images too. Removed for clarity.

So does

Code: Select all

<IfModule mod_expires.c>
  ExpiresActive on
  ExpiresByType text/javascript    "access plus 604800 seconds"
</ifModule>
I also gave it it's own line, like <filesMatch "\.js$">.
But nope.

What am I missing?
How do I get Cache-Control working for JS files too?


Thank you, Wim

Advertisement
gws
Joomla! Champion
Joomla! Champion
Posts: 6347
Joined: Tue Aug 23, 2005 1:56 pm
Location: South coast, UK
Contact:

Re: Htaccess cache-control does not work for JS files

Post by gws » Tue Sep 17, 2024 9:06 am


Mr. Wimpy
Joomla! Guru
Joomla! Guru
Posts: 553
Joined: Fri Dec 02, 2005 10:46 am
Location: The Netherlands

Re: Htaccess cache-control does not work for JS files

Post by Mr. Wimpy » Tue Sep 17, 2024 3:19 pm

Thank you, but no, it is not.

mod_expires (that is talked about in your link) works.
But mod_expires looks more complicated, because you need to figure out (all) the types.

I wanted to try mod_headers, because it looks more readable: cache-control based on file extension.
All (seem to) work, except .js files.

Advertisement

Post Reply

Return to “Performance - Joomla! 5.x”