Using caching
It is possible to opt-in for caching, to make your website faster. If you want to do this, make sure you take the following into account:
Enable caching inside site settings
To enable caching, go to your website's settings, and turn on caching under the Technical tab.
If you enable caching, all pages are being cached when they are called for the first time. So the very first request will still be the 'slow' version. After that request every visitor will be presented with the cached version. Keep in mind that this is a snapshot of a moment, so dynamic content will have to be prepared accordingly.
Use the dynamic
tag inside your theme
To keep using dynamic content, use the dynamic tag.
Make flash messages dynamic
There is some content that needs to be kept dynamic, even when cache is turned on. For example the flash message that visitors see after they submit a form. This message contains feedback, like a thank-you message, or errors, so it is important that it is shown to the visitor. You can make the flash message dynamic like this:
{% dynamic %}
{% if request.flash.alert %}
<p style="color:red;">
{{ request.flash.alert }}
</p>
<ul style="color:red;">
{% for error_msg in request.flash.errors %}
<li>{{ error_msg }}</li>
{% endfor %}
</ul>
{% endif %}
{% if request.flash.notice %}
<p style="color:green;">{{ request.flash.notice }}</p>
{% endif %}
{% enddynamic %}
Make authentication information dynamic
If you want to show when a user is logged in on a certain page, you should make that dynamic too.
{% dynamic %}
Welcome {{ authentication.current_user.name }}
{% enddynamic %}
Also, make sure to wrap any authenticate
tags in dynamic
! Or else the redirection to the login page will not work and the page contents will be visible in the cached version.
Optional: make forms dynamic
Plate uses multiple spam filter methods to make sure the forms on your site aren't misused by spammers. One of these methods checks how much time there was between the rendering of the form and the submitting, so we can guess if the form was submitted by a spambot. Obviously, when caching is enabled, this method is rendered useless. If you want Plate to be able to use this method too, you could wrap your forms in dynamic
tags. Keep in mind that this means the form fields will be rendered on the fly again. It is possible that this method is necessary to keep the spam filters working sufficiently.