I've came to a cache problem/question on one of my sites when I run a speed test and I failed caching test. I have very little knowledge in this area and I'd like to enhance it.

Documentation for {% header %} tag says that it set a new HTTP header in response and you can tell browser what to do (for example caching a page).

Documentation for {% cache %} tag say that it will cache a portion of your template.

So what's the difference in setting cache in HTTP header using {% header %} tag and {% cache %} tag?


The header tag sets an HTTP response header, which may be used to (among other things) tell the browser that the response content is "cacheable".

The cache tag tells Craft to cache the generated HTML on the server side (as a file).

  • Cache tag is clear to me what it does now. Do I need something else to cache a webpage except the code from documentation about the header tag? That's another question... Mar 20 '17 at 18:58
  • 1
    You wouldn't typically set the cache headers in Craft. That's usually a job for your Apache / nginx config. Mar 20 '17 at 19:15

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.