Menu

#1741 Cache Settings

Parent Category:
DPCalendar
Category:
System tasks
Last Updated:
Allon Moritz, Friday, 03 September 2021 18:41
Created:
Wednesday, 26 November 2014 21:16
Hits:
10367

Introduction

A cache is a method of storing previously retrieved information for a certain amount of time temporarily. For DPCalendar, when the first user requests a Joomla page with a DPCalendar (or plugin) on it, the data is retrieved from the database or calendar source. This takes time. Time to retrieve and process the information. When a second user requests the same page and the cache is enabled, the information is pulled from the cache (memory) instead of the original source. This is faster and uses less server resources. However, the information will be minutes old. For most users the delay is not noticed. If you are responsible to update the calendar, you might not see the update for several minutes after you made the change. Turning off the cache will show changes more quickly but can slow your site down considerably.

Joomla has a caching system as does DPCalendar and other extensions, they will be explained more deeply in the next chapters.

Joomla Cache

The best cache option for your site is the cache plugin, which caches the whole page. Means that no PHP code is executed at all, will relax your server and deliver the pages faster. You may find Joomla's cache settings in the Global Configuration > System tab. More Information can be found in this article from the official Joomla docs.

DPCalendar external events plugin cache

Every plugin which integrates external events into DPCalendar has options to choose a cache behavior to temporary save the external events on the Joomla site and to increase/decrease the cache time. You can even turn off the cache completely in the plugin settings.

Joomla cache

The Joomla cache option caches the events in a file in the cache folder within your Joomla installation. The time settings defines the lifespan of the cached files before the events are refetched from the remote system. This behavior is used since the beginning of DPCalendar and is the most stable option.

Database cache

The Database cache duplicates the events in the database dpcalendar_events table from your remote system. This brings the benefits that only the local database is touched during an event request and no connection is established to an external server. You should use this option together with a cron job as it fetches all the events for a timespan and updates the database. It's the option to use when you are an experienced server administrator as you need to set up a cron job and adjust probably some PHP settings in an ini file for long running operations. The following list shows the most important ones:

  • memory_limit
    Set it to a high value like 128M. If you still get memory errors, increase it till they stop.
  • max_execution_time
    Set it to 0 to disable max execution time on CLI tasks.

It is very much recommended to set up a cron job when database caching is enabled, which syncs the events completely in the background. Like that the visitor will never suffer from events sync during a page load. DPCalendar comes with a script which can be run on the command line and as cron job. It can be found in the folder /administrator/components/com_dpcalendar/cli and has the name eventsync.php. The following line can be copied into the crontab file to set up a cron job. Keep in mind that you need to properly set the cron execution time. For example if your cache time is 15 minutes, then you should run the cron job every 14 minutes like that the sync is always done on the command line.

*/14 * * * * /{my-path-php-executable}/php /{{joomla-root}}/administrator/components/com_dpcalendar/cli/eventsync.php

The database cache works the way that it fetches per default the last three years and the next three years of events. One year at a time and adds the events into the database. These settings can be controlled in the plugin parameters when database caching is enabled. If you have a lot of events, then it is recommended to lower the sync step value. It is done that way as incremental sync is not supported by every plugin and the initial sync will explode your database on large calendars. Additionally the admin can specify a comma separated list of calendar id's to sync with the "calids" parameter. For example "--calids=2,3" will only sync the external calendars 2 and 3.

Location Cache

When a location for a string is requested, during external event sync, then the location is stored in the database and is available for edit in the DPCalendar back end's Location Manager. If something is wrong with a location it can easily be corrected. If you want to refetch the locations, just delete them and on the next external event sync, they will be recreated.

Comments (0)

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.