Documentation
Cache plugin
Table of Contents ▼
Presentation
Temma can automatically manage the caching of pages generated by the Smarty view.
Configuration
This plugin must be one of the very first pre-plugins in the execution chain.
Indeed, if the requested page is already cached, the plugin will return it and stop processing. There is therefore no point in running pre-plugins which would only be useful in the event that the page must be generated.
On the other hand, an authentication plugin used to verify that the user has the right to access the page (for example) must be placed before in the execution chain.
You will therefore need to add a directive in the temma.json file (see the configuration documentation):
{
"plugins": {
// list of pre-plugins
"_pre": [
"\\Temma\\Plugins\\Cache"
]
}
}
Advanced configuration
It is possible to define additional configuration parameters, specifying them in an extended configuration section:
{
"plugins": {
"_pre": [
"\\Temma\\Plugins\\Cache"
]
},
"x-cache": {
// is used to define the data source (see "dateSources")
// by default, use the source named "cache"
"source": "memcache",
// list of strict URLs to cache
"url": [
"/articles/list",
"/pages/presentation"
],
// list of URL prefixes to cache
"prefix": [
"/documentation/",
"/legal/"
]
}
}
- source: Name of the data source to use for storing cached pages. If this value is not filled in, the plugin will look for a source named cache.
- url: List of strict URLs that can be cached. In this example, the pages /articles/list and /pages/presentation will be cached.
- prefix: List of URL prefixes that can be cached. In this example, all pages whose URL begins with /documentation/ or /legal/ will be cached.
When url and prefix directives are not set, all pages are likely to be cached.
Template variable
When the plugin detects that the page that is being accessed can be cached, it sets a template variable _temmaCacheable, giving it the Boolean value of true. This variable will be used by the Smarty view, to cache the generated HTML code before sending it to the browser.
It is strongly recommended not to modify this value. However, you can access it in read mode.
Previous: | API plugin helper |
Next: | Language plugin helper |
Table of Contents
- Migration : How to upgrade from Temma 1.x to version 2
- Installation : Download Temma and install it to start your web project
- Configuration : All the configuration directives of the etc/temma.json file and the optional environment variables
- External libraries : How to use external function libraries
- Routing : Temma's default routing system, and advanced routing
- Log : Use of the log system, management by criticality levels
- Controllers : Essential parts of your web application
- Views : Smarty templates or JSON/CSV/RSS/iCal/INI exports
- Dependency injection : The backbone of your application developments
- Sessions : Extension of user sessions managed by PHP
- Data sources : Unified data access management
- Model : How to use DAOs to access databases
- Execution flow : How to manage the execution flow, between plugins and the controller
- Plugins : How to use plugins, and create your own plugins to modularize your code
- Attributes : How to filter access to controllers and actions
- Tests : To write automated integration tests.
- Command-line interface : To create executable scripts on the command line, automatically initialized by Temma
-
Helpers :
Items offered by Temma to help you in various circumstances
- Command-line scripts
-
Controller + plugin
- Auth : Controller and plugin to manage user authentication
- Plugins
- Attributes
-
Smarty plugins
- urlize : Modifier to transform a text into an URL
- filenamize : Modifier to transform a text into a file name
- nbsp : Modifier to transform spaces into non-breakable spaces
-
Utility objects
- ANSI : To format texts written to standard output
- BaseConvert : To do digital base conversions
- DataFilter : To filter and validate data
- Email : To send emails
- HTMLCleaner : To clean up an HTML stream coming from a WYSIWYG editor
- IniExport : To export data in INI format
- Json : To read JSON streams that may contain comments
- Lock : To lock access to a file, or the execution of the current PHP script
- Registry : To properly store global variables
- Smarty : To process Smarty templates outside the view
- Term : Terminal management (TTY)
- Text : Different treatments on character strings
- Timer : To manage stopwatches