Are different cache saved for Mobile / Tablet / localisations or do we have to take care of this?

I.e. if i use:

{% if craft.request.isMobileBrowser() %} 

will the response be cached for desktop users as well?


Craft makes no distinction whether it's caching for mobile, tablet, desktop, etc., so it'll need to be taken care of on the template end.

You can easily do that with the "using key" parameter of the {% cache %} tag, though.

{% if craft.request.isMobileBrowser %}
    {% set cacheKeyType = 'mobile' %}
{% else %}
    {% set cacheKeyType = 'desktop' %}
{% endif %}

{% cache using key "page-header-" ~ cacheKeyType %}
{% endcache %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.