1

Having spoken to our 'ops guy' I've come to understand that if Craft CMS can render flat html or cache some of the pages then it makes thing a lot quicker to load etc.

Is this something craft can do? Also will it will be ok using assets from a cloud front CDN setup too?

  • It seems this question was asked previously, so you might find some advice there: Are there any file-based static cache options for Craft CMS? – Simon East Jun 20 '17 at 21:40
  • @SimonEast Despite the similarities, I believe these two people are actually asking about different things. This seems clear based on their (very different) accepted answers. One poster is specifically looking for flat-file caching, the other is looking for flat files "or something", and is quite happy with a non-file solution. – Lindsey D Jun 20 '17 at 22:08
4

I've come to understand that if Craft CMS can render flat html or cache some of the pages then it makes thing a lot quicker to load

I believe you're looking for the the {% cache %} tag, which will – on the first page request – capture the compiled HTML output inbetween the opening and closing of the tag, and write it to the database. On subsequent requests, Craft will pull and output the compiled (flat) HTML using a single SQL query (until the cache expires, is cleared manually or any entries, categories etc. involved is changed). This means that for most pageloads, complex database queries or taxing PHP operations (Twig templates are compiled to PHP) can be eliminated, which is usually a performance boost.

will it will be ok using assets from a cloud front CDN setup too?

Yep, Craft is easily set up with external asset sources, and S3/CloudFront is supported. You will need a Craft Pro license, though.

|improve this answer|||||
  • 2
    Great answer; minor nitpick: S3 and CloudFront are 2 different services (as much as Amazon would like you to use both). You don't need to host your assets on S3 (anymore unless you want) to take advantage of CloudFront and you don't need a Craft Pro account to use any CDN (assuming the CDN supports using origin pull) since every Craft version supports external assets. – RitterKnight Sep 13 '15 at 23:08
  • The cache tag is definitely a step in the right direction, but it still introduces a not-insignificant delay by bootstrapping Yii and Craft. The way around that is to use a static file cache as mentioned in this thread: craftcms.stackexchange.com/a/14681/5437 – Simon East Jun 20 '17 at 21:44
2

Craft can render html yes... it's a pretty core element of it lol.

By flat do you mean completely non-dynamic? Normally "flat html" means to just use "html" files and not rely on any sort of dynamic system like a CMS.

Or do you mean to flatten the code? As in to minify it? In which case craft can do that yes. {% spaceless %}<html> </html>{% endspaceless %} will become <html></html>

On top of that it does have its own {% cache %} tags too (which definitely speeds things up), again you will need to wrap the appropriate cache tags around the bits of your site you want to cache.

Also be wary of cloudfront, it doesn't always speed things up, sometimes can make websites run slower. Though it does offer DDOS protection.

|improve this answer|||||

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.