lets start with the definition of Joomla Cache : “The mechanism that offers users a stored view of (part of) a web page so that does not have to be pulled from the database. Joomla core offers three levels of caching: Page caching, View caching and Module caching. By default, Joomla does not cache any content. When caching is switched on, the stored views for this are stored in the filesystem for Joomla ../cache/page/ folder”. (Source: Joomla Glossary)
Cache settings in Joomla
There are 3 places where one can access these settings.
- Global configuration - Progessive / conservative cache
- System plugin - Page caching / Browser caching
- Module level cache for all modules
Points to note
- Joomla generates dynamic content, cache if enabled renders same cached content to all
- Cache is not applicable for logged in users, as logged in users requires the system to generate user unique content based on permissions or activity
- Modules rendering dynamic content should not be cached.
- Keep cache off during site development
- System cache plugin settings take precedence over global config settings
1. Page Caching
Turned off by default in the Joomla. Once enabled it starts caching copies of the rendered pages of the site and on next requests the cached pages is displayed bypassing the database queries. Remember this works only for site visitors, logged in users are not provided the cached pages.
To enable this caching:
- Log into your Joomla Administrator
- Go to Extensions >> Plugin Manager from the top menu
- Search for "cache" in the filter box
- Go to System - Cache plugin >> Detail to activate this plugin
- Go to System - Cache plugin >> Basic info to enable/disable the “Use browser caching” option
1a. Browser caching
Once enabled the site sends a "304 not modified" header to the browser if the page has been cached in the browser, so the server does not have to render the page for user again in that specific browsing session.
2. View caching and Module caching
Different from Page caching, View and Module caching only caches a part of the page. To configure View and Module caching, go to Global Configuration and follow the steps below.
- Log into your Joomla Administrator
- Go to Global Configuration >> System
- Find the “Cache Settings” section
- Set “Cache” to “ON - Conservative caching” or “ON - Progressive caching” (Differences between these two will be covered in the next section)
- Set “Cache Handler” to the caching software installed on your server (Here we use “File”)
- Set “Cache Time” to your desired duration (in minutes) between the caches (15 for example)
- Click Save & Close
Progressive or Conservative Caching
Progressive caching caches the content for each unique visitor while Conservative caching delivers the same cached content to all visitors. If your modules have static content use progressive caching otherwise select conservative caching.
Cache lifetimeThis is the duration in which a copy of the page is stored before being replaced with a new one. The time setting depends on the frequency of your content update. If your page has new content posted every few minutes, keep this time setting low and vice versa.
3. Module Cache
One should enable module cache for modules with static content only and then it works well with conservative caching. Modules with dynamic content should not be cached.
Purge expired cache
After caching is enabled, cache files will be stored to disk and you need to delete those expired cache files to achieve better server performance.
To purge expired cache in Joomla 3:- Log into your Joomla Administrator
- Go to System >> Purge Expired Cache from the top menu
- Click the Purge Expired icon in the top left menu to Purge Expired Cache in Joomla 3
Purge expired cache will not delete all cache files but only clear those cache files before a specified time. This is a rather long and resource-taking process which we only recommend you to implement when your Joomla server is less busy.
Turn off cache
It is true that caching can speed up your site loading by delivering the already cached pages to visitors. However, during site development, you may consider disable caching to be able to see your changes instantly.
To disable Page caching:- Log into your Joomla Administator
- Go to Extensions >> Plugin Manager >> System Cache from the menu
- Disable the plugin System Cache
To disable View caching and Module caching:
- Log into your Joomla Administrator
- Go to Global Configuration >> System
- Under Cache Settings change the Cache to Off - Caching disabled
- Click Save & Close
Hope you enjoy today’s tutorial and just stay tuned for more topics to come. See ya!