Monday, June 22, 2015

Web Caching in BlueBox

A new front-end caching feature has been introduced into Bluebox. This allows for mostly static, front-end content to be cached to speed up load time and reduce overall server load.

Caching is turned on via the following config settings:

 $system_cache_frontend_pages=0; //caches non-system/logged out pages
 $system_cache_frontend_pages_period=24; //number of hours before refreshing the cache

Setting $system_cache_frontend_pages = 1 will trigger the system to start caching pages as they're generated, while the period (in hours) will determine how long a page will be cached for before being refreshed.

Front end caching will be affected by the following

1. Caching is only utilized when there's no user session (ie. logged out)
2. "Post" request methods always ignore caching (such as sending contact forms).
3. Caching can be manually ignored by adding $global['nocache']=1 to the url string
4. Front-end template groups can be set to ignore caching by adding them to the bb_web_cache bbsetting: bbsetting_exclude_templates
5. Specific urls (that would otherwise be included in caching) can be excluded from caching by setting them in bb_web_cache bbsetting: bbsetting_exclude_urls - does partial matching
6. Any url with a "class" variable set ignores the cache
7. However, it is possible to include urls with "class" in them by setting them in bb_web_cache bbsetting: bbsetting_include_urls - does partial matching

The cache can be flushed manually by going to Publishing -> CMS -> Web Cache from the main LHS menu.

Cache can also be flushed via code by calling bb_web_cache->flush()  . An optional "pattern" parameter can be passed to only flush cache files matching the pattern. It must be a regular expression. This is useful when used in conjunction with a POST plugin function on a module that affects front-end pages (deleting the cache on changes to fresh the content immediately).

No comments:

Post a Comment