Cache HTTP and HTTPS seperately using {% cache %} we have a page that can be accessed both via regular HTTP and HTTPS. We now stumbled across an issue that if a page has been loaded via HTTP (and the content has thus been cached) and another user tries to load the same page via HTTPS afterwards, the browser complains about loading non-secure content, as Craft serves the cached content (e.g. URLs to images) that was generated while accessing the page via HTTP.

Shouldn't the {% cache %} tag take the protocol into account when comparing URLs?
Is there a known workaround or best practice for handling this?

Thanks,

Clemens
Something like this would work:

{% if craft.request.isSecure() %}
    {% set cacheKey = 'secure' %}
{% else %}
    {% set cacheKey = 'insecure' %}
{% endif %}

{% cache using key cacheKey %}
    ...
{% endcache %}


See here for more info.