1

I am fairly new to Craft CMS but have a good understanding of it. I have a page that has a Matrix field to display staff photos and their roles.

On the initial load of this page, it is slow, it takes nearly 22 seconds. It is only 1meg of data.

Some stats on the initial load: • DB queries 200 • 22 seconds to load

Once it has been loaded into the cache it is much better: • DB queries 165 • 1.6 seconds to load

I have tried eager loading the image field and image transform with no speed increase:

{% set teamMembers = entry.teamMembers.with([
        ['blockType:image', {
            withTransforms: ['teamMemberSmall']
        }]
    ]).all() 
%}

It's not a huge amount of data so I would have thought this could be much faster. Based on the profiling it looks like it is the asset transform generation that is killing the page. Any tips or tricks I can do to get that initial page load faster? Can the assets be pre-generated?

Server stats:

  • PHP 7.2
  • MYSQL 5.5
  • Memory Limit 256mb
1

I used to have the same issue then I started using Eager Loading Element. It allows you to speed up your craft cms templates by fetching matrix from the database more efficiently.

You can refer to this link which might help you for further understanding of Eager Loading.

| improve this answer | |
  • Thanks for the reply, eager loading helps marginally. After further investigation my issue that was slowing it down on the first load was the image transform generating the images. It would be good if these could be generated from the control panel. – Pedro May 2 '19 at 20:34

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.