Who this is for. The developer whose template change shows on one environment and not another, and the person deploying to production. Afterwards you will know when a template change takes effect, what clears the compiled templates, and when the compiled templates are not the cause at all.
Two engines, one arrangement
Neither engine reads a template file on every request. Each compiles the template into PHP the first time it is needed and runs the compiled version from then on. Where that compiled code is kept depends on the environment's mode, which is production unless the environment is configured otherwise:
| Smarty | Twig | |
|---|---|---|
| Production: where compiled templates are kept | The site's .cache folder, one file per template | The site's .cache folder, in two-letter subfolders |
| Production: a template file that changed | Recompiled on the next request: Smarty compares the file's modification time with the compiled copy | Not noticed: Twig keeps serving the compiled copy until the template cache is cleared |
| Every other environment | Recompiled on every request, in a temporary folder | Compiled on every request, with no compiled cache |
So on a development environment a saved template shows on the next request in either engine, and there is nothing to clear. On production the two engines differ, which matters only when a file reaches production without a deploy.
What clears the compiled templates
- A deploy through version control. When a push is deployed, the platform clears the template cache, the page cache and the CDN cache of static files, for every environment that uses the same site folder. A deployed template change is live on the next request in either engine.
- Clear Cache on the environment in the admin. It clears the page cache, the CDN cache of static files and the template cache, without a deploy.
- Nothing else. A file copied to production by FTP clears nothing. Smarty notices the new file; Twig does not until someone clears the cache, and in both engines the page cache may still serve the old page.
The template cache is the compiled code and nothing more. Clearing it costs one compile per template on the next request that needs it, and loses no content.