Class CacheHelper
CacheHelper helps create full page view caching.
When using CacheHelper you don't call any of its methods, they are all automatically called by View, and use the $cacheAction settings set in the controller.
- AppHelper
- CacheHelper
Link: https://book.cakephp.org/2.0/en/core-libraries/helpers/cache.html
Deprecated:
This class will be removed in 3.0. You should use a separate response cache like Varnish instead.
Copyright: Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
License: MIT License
Location: Cake/View/Helper/CacheHelper.php
Properties summary
-
$_counter
protectedinteger
Counter used for counting nocache section tags. -
$_match
protectedarray
Array of string that are replace with there var replace above. The strings are any content inside
<!--nocache--><!--/nocache-->
and includes the tags in views -
$_replace
protectedarray
Array of strings replaced in cached views. The strings are found between
<!--nocache--><!--/nocache-->
in views
Method Summary
-
_enabled() protected deprecated
Is CacheHelper enabled? should files + output be parsed. -
_parseContent() protected deprecated
Parse a file + output. Matches nocache tags between the current output and the current file stores a reference of the file, so the generated can be swapped back with the file contents when writing the cache file.
-
_parseFile() protected deprecated
Parse file searching for no cache tags -
_parseOutput() protected deprecated
Parse the output and replace cache tags -
_replaceSection() protected deprecated
Munges the output from a view with cache tags, and numbers the sections. This helps solve issues with empty/duplicate content.
-
_stripTags() protected deprecated
Strip cake:nocache tags from a string. Since View::render() only removes un-numbered nocache tags, remove all the numbered ones. This is the complement to _replaceSection.
-
_writeFile() protected deprecated
Write a cached version of the file -
afterLayout() public deprecated
Parses the layout file and stores content for cache file building. -
afterRenderFile() public deprecated
Parses the view file and stores content for cache file building. -
cache() public deprecated
Main method used to cache a view
Method Detail
_enabled() protected deprecated ¶
_enabled( )
Is CacheHelper enabled? should files + output be parsed.
Returns
_parseContent() protected deprecated ¶
_parseContent( string $file , string $out )
Parse a file + output. Matches nocache tags between the current output and the current file stores a reference of the file, so the generated can be swapped back with the file contents when writing the cache file.
Parameters
- string $file
- The filename to process.
- string $out
- The output for the file.
Returns
Updated content.
_parseFile() protected deprecated ¶
_parseFile( string $file , string $cache )
Parse file searching for no cache tags
Parameters
- string $file
- The filename that needs to be parsed.
- string $cache
- The cached content
_parseOutput() protected deprecated ¶
_parseOutput( string $cache )
Parse the output and replace cache tags
Parameters
- string $cache
- Output to replace content in.
Returns
with all replacements made to
_replaceSection() protected deprecated ¶
_replaceSection( )
Munges the output from a view with cache tags, and numbers the sections. This helps solve issues with empty/duplicate content.
Returns
The content with cake:nocache tags replaced.
_stripTags() protected deprecated ¶
_stripTags( string $content )
Strip cake:nocache tags from a string. Since View::render() only removes un-numbered nocache tags, remove all the numbered ones. This is the complement to _replaceSection.
Parameters
- string $content
- String to remove tags from.
Returns
String with tags removed.
_writeFile() protected deprecated ¶
_writeFile( string $content , string $timestamp , boolean|null $useCallbacks = false )
Write a cached version of the file
Parameters
- string $content
- view content to write to a cache file.
- string $timestamp
- Duration to set for cache file.
- boolean|null $useCallbacks optional false
Whether to include statements in cached file which run callbacks, otherwise null.
Returns
success of caching view.
afterLayout() public deprecated ¶
afterLayout( string $layoutFile )
Parses the layout file and stores content for cache file building.
Parameters
- string $layoutFile
- Layout file name.
afterRenderFile() public deprecated ¶
afterRenderFile( string $viewFile , string $output )
Parses the view file and stores content for cache file building.
Parameters
- string $viewFile
- View file name.
- string $output
- The output for the file.
Returns
Updated content.