craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.27k stars 635 forks source link

[4.4.5]: ControlPanel loading times are slow #12987

Closed LeoWie93 closed 1 year ago

LeoWie93 commented 1 year ago

What happened?

Description

After upgrading our CMS the navigation inside the ControlPanel became extremly slow.

Here are the loadtimes for the settings page: image

image

Please tell me what further informationes you would need of me.

Thank you for your help and insight in advance

Craft CMS version

4.4.5

PHP version

8.2

Operating system and version

Linux 6.1.21-1-lts

Database type and version

MySQL 8.0.32

Image driver and version

Imagick 3.7.0 (ImageMagick 6.9.11-60)

Installed plugins and versions

Element API 3.0.1.1

Redactor 3.0.4

Super Table 3.0.7

Typed link field 2.1.5

brandonkelly commented 1 year ago

What version were you updating from?

As a starting point, you can try running composer dump-autoload -o.

LeoWie93 commented 1 year ago

Local Dev

@brandonkelly we were upgrading from 3.7.x to 4.4.x. At first i did not pay much attention to this issue because my workstation is not the best and is getting slower.

These particular loading times made me author this issue but where improved after completely deleting and setting up this project again on my local machine.

Environments

On other environments it is not that bad. But it is more an inconvenience. For example, not loading of icons or the content of a redactor fields. It sometimes takes half a second for them to load which degrades the user experience.

image

Other projects do not have this issue. Of course this project is much bigger with more entries. I am not sure if my expectations are unreasonable or maybe the hardware is to weak. But all recommendations are met.

composer dump-autload -o did not really improve the loading time of js files etc.

brandonkelly commented 1 year ago

The way control panel resources (like the icon font that’s missing in your screenshot) get loaded hasn’t changed at all in Craft 4.

I can tell you how it’s supposed to work, and maybe that will help you identify the culprit.

The resources are distributed with Craft in the src/web/assets folder as asset bundles. Each asset bundle has a source publishable directory (e.g. src/web/assets/cp/dist.

When an asset bundle is registered to a request, Craft/Yii ensures that directory is published and up-to-date into the web/cpresources/ folder. (The exact location will depend on your resourcesBasePath config setting.) Then the browser is given a URL to the published asset bundle, based on your resourceBaseUrl setting.

When the browser requests the resource files, typically the files will exist and be served by your web server directly, which should be very fast. However there’s a chance the files won’t actually exist, e.g. if it’s a load-balanced environment and the resource request hit a different server than the one that had published the files to begin with. In that case, the web server should be configured to route the 404ing request off to Craft, which will look up which asset bundle’s files were requested, “re”-publish it, and then read out the requested file in its response.

So off the top of my head, here’s a couple things to check:

LeoWie93 commented 1 year ago

@brandonkelly thank you. I've found the problem: image

While upgrading to Craft 4 and using the GeneralConfig class this overwrite must have sneaked in and all the ressources where always newly generated.

Sorry for taking away your time with an issue like that. And we greatly appreciate your help.

brandonkelly commented 1 year ago

Glad you got it sorted!