Page 1 of 1

How to cache Joomla site?

Posted: Sat Mar 30, 2024 9:30 pm
by pl71
It has been discussed probably a thousand times.
What is the best approach for caching a small site like a blog updated weekly?

Presently I have in Global Configuration:
System Cache: ON - Conservative caching
Cache handler: File
Platform-specific caching: No
Cache time: 30 min
Path to cache folder: [BLANK]


Additionally, I have the following code in .htaccess file:

Code: Select all

<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 week"
# Images
ExpiresByType image/x-icon "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
...
...
</IfModule>
This code is circulating in many sites, and I believe it is correct without errors.

Surprisingly https://pagespeed.web.dev is complaining:
Serve static assets with an efficient cache policy --- 13 resources found
The problem was mostly in CSS files. PageSpeeds wants CSS to be cached for more than 2 months, though JS could be only month cached. Strange.
Presently mine:

Code: Select all

ExpiresByType text/css "access plus 6 month"
For me, caching is doubled, but I'm not sure if this is good or bad.
What do you think about all that? Is it OK .htaccess to include ExpiresByType directives when Caching is ON in Global Configuration? Or are they different things?

Re: How to cache Joomla site?

Posted: Sun Mar 31, 2024 10:07 am
by pe7er
I'd recommend to set "Platform-specific caching" to "Yes".

Otherwise you run into problems with visitors from different devices:
a mobile visitor will let Joomla cache a page for a mobile device. When the next visitor with desktop device visits the same page, the cached for mobile page will be displayed, hence that visitor will see a very small site.

Re: How to cache Joomla site?

Posted: Sun Mar 31, 2024 5:00 pm
by pl71
Thanks, Peter.
What about .htacces in this case? Is it OK to remain like that?