Caching the Subscribe & Download Links
Note: The instructions below only apply to VTCalendar 2.3.0 and later.
When hundreds or thousands of users subscribe to your calendar via the 'Subscribe & Download' page, this can put a heavy load on your server.
If you find your self in this situation, you have a few options:
- Cache all export URLs using a caching feature built into your Web server (i.e. Apache 2.2's mod_cache) or a third-party tool or plugin (i.e. Squid).
- Create static versions of the RSS/iCal files and instruct VTCalendar to link to them.
It is recommended that you use the first option if it is available to you.
Apache 2.2's mod_cache
Note: You must have access to your server's httpd.conf file in order to use this method.
- Load
cache_module in your httpd.conf file: (This line may already exist and just needs to be uncommented)
LoadModule cache_module modules/mod_cache.so
- Load either disk_cache_module or mem_cache_module in your httpd.conf file:
(These lines may already exist and just need to be uncommented)
LoadModule disk_cache_module modules/mod_disk_cache.so
- or -
LoadModule mem_cache_module modules/mod_mem_cache.so
- Enable caching for
./export/export.php in your VTCalendar folder:
CacheEnable disk /vtcalendar/export/export.php
- or -
CacheEnable disk /vtcalendar/export/export.php
For more details about mod_cache see the Caching Guide on Apache's Web site.
Generating and Linking to Static RSS/iCal Files
VTCalendar includes some built-in features and scripts for caching the RSS and iCal files.
To set this up, do the following:
- If you configured this during the install then you may skip step 2 and 4.
- Configure the output folder in config.inc.php:
- Windows:
define("CACHE_SUBSCRIBE_LINKS_OUTPUTDIR", "C:\\inetpub\\wwwroot\\vtcalendar\\cache\\subscribe\\");
- Linux:
define("CACHE_SUBSCRIBE_LINKS_OUTPUTDIR", "/var/www/html/vtcalendar/cache/subscribe");
- Generate the first RSS/iCal files:
- Windows:
- Copy
cache/generate.bat.example to cache/generate.bat
- Edit the file if you need to add additional directories to the path (such as the PHP folder).
- Double click
cache/generate.bat
- Linux:
- Change to the VTCalendar root folder.
cp cache/generate.sh.example cache/generate.sh
- Edit the file if you need to add additional directories to the path (such as the PHP folder).
bash cache/generate.sh
- Configure VTCalendar to use the cached files:
define("CACHE_SUBSCRIBE_LINKS", true);
define("CACHE_SUBSCRIBE_LINKS_PATH", 'cache/subscribe/'); (if necessary)
- Use your browser to verify that VTCalendar is linking to the files and that the files are valid.
- Schedule the generate script to run:
- Windows:
- Open the "Control Panel"
- Open the "Schedule Tasks" item (you may need to switch to classic view)
- Double click "Add Scheduled Task"
- Complete the wizard to run the script every N minutes. Depending on how much time the script needed to run in step 2, it is recommended you use either 5, 10, 15 or 30 minutes (anything higher and the files will get stale).
- Linux:
- Edit your crontab file. This is done by either editing the file at
/etc/crontab or running crontab -e
- Add the following line:
*/N * * * * someuser /path/to/bash /path/to/vtcalendar/cache/generate.sh
- Replace N with the number of minutes. Depending on how much time the script needed to run in step 2, it is recommended you use either 5, 10, 15 or 30 minutes (anything higher and the files will get stale).
- Replace
someuser with your username or a user that has write access to the folder you specified by CACHE_SUBSCRIBE_LINKS_OUTPUTDIR.
- Replace
/path/to/bash with the absolute path to bash. This is usually /bin/bash .
- Replace
/path/to/vtcalendar with the absolute path to the VTCalendar root folder.
- Save the file.
- Wait N minutes to see if the files were updated.
|