Problem/Motivation
Currently we can configure to cache a whole display or a single pane. However, often it would be handy to cache whole parts of a display.
The advantage of caching whole regions is less effort in configuration and faster cache handling.
There are caching handler that uses tokens to generate keys (e.g. Cache Actions) has to do token evaluation over and over again for single pane caches.
Grouping those panes in regions can speed up the processing - you could even create "virtual" groups in your layout just for the sake of caching.
Proposed resolution
- Unify the cache settings handling - similar to the style handling which is unified for all items.
-
- Add a check to see if region caching is enabled in
panels_renderer_standard::render_layout(), if so don't callpanels_renderer_standard::render_panes()but onlypanels_renderer_standard::render_regions(). - Add an optional parameter to
panels_renderer_standard::render_panes()to specify which panes to render. - Add a call to
panels_renderer_standard::render_panes()inpanels_renderer_standard::render_regions()and use the new parameter to just render the region panes. - Add cache handling to
panels_renderer_standard::render_regions(). Use an instance ofpanels_cache_object, which again takes care of the css / js delta handling. The region is cached as a "pane", this means it passes a cache config object intopanels_get_cached_content()/panels_set_cached_contentas panes do, however the pid is'reg:' . $region_id.
- Add a check to see if region caching is enabled in
Remaining tasks
Clarify the trade-offs.
Possible issues:
-
The global order of the pane rendering changes: Currently
panels_renderer_standard::prepare_panes()takes care of ordering the panes according to theirrender first/render lastflags. Since the panes where rendered all at once the order was global. However, with this patch the panes are rendered per region. The order now is respected per region but not globally.
To make users aware of this a warning message is displayed if region caching is used with contents that have one of those flags.
User interface changes
New links to configure the caching in the region settings dropdown.
API changes
New methods:
panels_renderer_standard::has_region_caching(): Returns TRUE if the displays has a region with enabled caching.panels_renderer_editor::get_cache_links($type, $pid): Fetches the cache settings links for the given type / id.panels_renderer_editor::get_cache($type, $pid): Returns the caching settings for the given type / id.panels_renderer_editor::get_region_caching_warning(): Returns a html element with a warning if content types with a render order flag are present while region caching is used.panels_renderer_editor::command_update_region_caching_warning(): Add an ajax command that refreshes the region caching warning.
New properties:
panels_renderer_standard::$rendered_empty: Storage to keep track of rendered elements that returned an empty output. Used to avoid duplicated rendering because of empty output.
Method signature changes:
<code>panels_renderer_standard::render_panes($panes_to_render = array()): Has now a parameter to specify which panes to render. Is optional, thus backward compatible.
Data model changes
New region caching settings in the display:
$display->panel_settings now has the key cache_settings.
It holds the cache settings for the regions.
Example:
'cache_settings' => array(
'header' => array(
'method' => 'simple',
'settings' => array(
'lifetime' => '604800',
'granularity' => 'context',
),
),
| Comment | File | Size | Author |
|---|---|---|---|
| panels-region-caching.patch | 22.46 KB | das-peter |
Comments
Comment #1
japerryDrupal 7 is no longer supported, closing.