Skip to main content
Commonmark migration
Source Link

You embed IS being "cached" - saved to the Stash database table as a variable - but it's not being parsed before being cached. That is because, out of the box, a Stash embed works just like an EE embed: the content of the embed file is included into the host template and then parsed at runtime.

The parsing stage of an embed is controlled by the parse_stage parameter.


##parse_stage="set"

parse_stage="set"

Parse the template the first time it is read from the file, and cache the rendered result. Subsequent retrievals will return the cached template from the database and not the original template file (unless you have set replace="yes" parameter or have set stash_file_sync = TRUE in your config).

##parse_stage="get"

parse_stage="get"

Read the template file and cache it to the database. When output to the template on the first and subsequent retrievals the template will be parsed. This is similar to how EE templates work.

##parse_stage="both"

parse_stage="both"

Parse the template before caching AND after it is retrieved. This can be very useful when enclosing regions of your template with {stash:nocache}{/stash:nocache}. On SET the template code inside {stash:nocache} will not be parsed, but everything else will. On GET it will be parsed. This provides a way to partially cache some of your template code while leaving other areas dynamic.


So to be clear: if you plan to cache a partially-rendered template with regions escaped with {stash:nocache}{/stash:nocache} tag pairs, then you will need to use parse_stage="both" on your main Stash embed.

Also please note that partial caching is incompatible with static caching, as a static-cached page does not pass through EE or even PHP at all - it's just served as plain old HTML. However, you can of course use javascript/ajax to update dynamic elements within a static-cached page.

You embed IS being "cached" - saved to the Stash database table as a variable - but it's not being parsed before being cached. That is because, out of the box, a Stash embed works just like an EE embed: the content of the embed file is included into the host template and then parsed at runtime.

The parsing stage of an embed is controlled by the parse_stage parameter.


##parse_stage="set"

Parse the template the first time it is read from the file, and cache the rendered result. Subsequent retrievals will return the cached template from the database and not the original template file (unless you have set replace="yes" parameter or have set stash_file_sync = TRUE in your config).

##parse_stage="get"

Read the template file and cache it to the database. When output to the template on the first and subsequent retrievals the template will be parsed. This is similar to how EE templates work.

##parse_stage="both"

Parse the template before caching AND after it is retrieved. This can be very useful when enclosing regions of your template with {stash:nocache}{/stash:nocache}. On SET the template code inside {stash:nocache} will not be parsed, but everything else will. On GET it will be parsed. This provides a way to partially cache some of your template code while leaving other areas dynamic.


So to be clear: if you plan to cache a partially-rendered template with regions escaped with {stash:nocache}{/stash:nocache} tag pairs, then you will need to use parse_stage="both" on your main Stash embed.

Also please note that partial caching is incompatible with static caching, as a static-cached page does not pass through EE or even PHP at all - it's just served as plain old HTML. However, you can of course use javascript/ajax to update dynamic elements within a static-cached page.

You embed IS being "cached" - saved to the Stash database table as a variable - but it's not being parsed before being cached. That is because, out of the box, a Stash embed works just like an EE embed: the content of the embed file is included into the host template and then parsed at runtime.

The parsing stage of an embed is controlled by the parse_stage parameter.


parse_stage="set"

Parse the template the first time it is read from the file, and cache the rendered result. Subsequent retrievals will return the cached template from the database and not the original template file (unless you have set replace="yes" parameter or have set stash_file_sync = TRUE in your config).

parse_stage="get"

Read the template file and cache it to the database. When output to the template on the first and subsequent retrievals the template will be parsed. This is similar to how EE templates work.

parse_stage="both"

Parse the template before caching AND after it is retrieved. This can be very useful when enclosing regions of your template with {stash:nocache}{/stash:nocache}. On SET the template code inside {stash:nocache} will not be parsed, but everything else will. On GET it will be parsed. This provides a way to partially cache some of your template code while leaving other areas dynamic.


So to be clear: if you plan to cache a partially-rendered template with regions escaped with {stash:nocache}{/stash:nocache} tag pairs, then you will need to use parse_stage="both" on your main Stash embed.

Also please note that partial caching is incompatible with static caching, as a static-cached page does not pass through EE or even PHP at all - it's just served as plain old HTML. However, you can of course use javascript/ajax to update dynamic elements within a static-cached page.

Source Link
Mark Croxton
  • 5.2k
  • 16
  • 15

You embed IS being "cached" - saved to the Stash database table as a variable - but it's not being parsed before being cached. That is because, out of the box, a Stash embed works just like an EE embed: the content of the embed file is included into the host template and then parsed at runtime.

The parsing stage of an embed is controlled by the parse_stage parameter.


##parse_stage="set"

Parse the template the first time it is read from the file, and cache the rendered result. Subsequent retrievals will return the cached template from the database and not the original template file (unless you have set replace="yes" parameter or have set stash_file_sync = TRUE in your config).

##parse_stage="get"

Read the template file and cache it to the database. When output to the template on the first and subsequent retrievals the template will be parsed. This is similar to how EE templates work.

##parse_stage="both"

Parse the template before caching AND after it is retrieved. This can be very useful when enclosing regions of your template with {stash:nocache}{/stash:nocache}. On SET the template code inside {stash:nocache} will not be parsed, but everything else will. On GET it will be parsed. This provides a way to partially cache some of your template code while leaving other areas dynamic.


So to be clear: if you plan to cache a partially-rendered template with regions escaped with {stash:nocache}{/stash:nocache} tag pairs, then you will need to use parse_stage="both" on your main Stash embed.

Also please note that partial caching is incompatible with static caching, as a static-cached page does not pass through EE or even PHP at all - it's just served as plain old HTML. However, you can of course use javascript/ajax to update dynamic elements within a static-cached page.