Skip to content

Commit

Permalink
Never Cache Twig documented
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanMPierson committed Feb 8, 2017
1 parent 5d805db commit cc5efec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions pages/01.basics/05.grav-configuration/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ The **Pages** section of the `system/config/system.yaml` file is where you set a
- **markdown**: Enable or disable the processing of markdown on the front end. Can be set `true` or `false`.
- **twig**: Enable or disable the processing of twig on the front end. Can be set `true` or `false`.
* **twig_first**: Process Twig before markdown when processing both on a page. Can be set `true` or `false`.
* **never_cache_twig**: Enabling this will allow you to add a processing logic that can change dynamically on each page load, rather than caching the results and storing it for each page load. This can be enabled/disabled site-wide in the **system.yaml**, or on a specific page. Can be set `true` or `false`.
* **events**:
- **page**: Enable page-level events. Can be set `true` or `false`.
- **twig**: Enable Twig-level events. Can be set `true` or `false`.
Expand Down
12 changes: 12 additions & 0 deletions pages/02.content/02.headers/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,18 @@ By default, Grav will cache the contents of the page file to ensure things run a

An example of this is when you are using dynamic Twig variables in your content. The `cache_enable` variable allows this behavior to be overridden. We will cover Twig Content variables in a later chapter. Valid values are `true` or `false`.

### Never Cache Twig

```ruby
never_cache_twig: true
```

Enabling this will allow you to add a processing logic that can change dynamically on each page load, rather than caching the results and storing it for each page load. This can be enabled/disabled site-wide in the **system.yaml**, or on a specific page. Can be set `true` or `false`.

This is a subtle change, but one that is especially useful in modular pages as it keeps you from having to constantly disable caching when you're working with it. The page is still cached, but not the Twig. The Twig is processed after the cached content is retrieved. For modular forms, it now works with just this setting rather than having to disable the modular page cache.

!! This is not compatible with `twig_first: true` currently because all processing is happening in the one Twig call.

### Process

```ruby
Expand Down

0 comments on commit cc5efec

Please sign in to comment.