38

Generally you’ll just want to cache areas of your templates that are going to trigger a lot of database queries, or fetch a lot of data, since those are going to have the biggest hit on your site’s performance. Matrix field loops that have relationship fields inside them (Entries/Assets/etc.) are a good example, since each Matrix block is going to come with ...


30

When working with multiple environments you likely want to disable caching for all but one environment, because Craft saves the absolute url to entries/assets in the cache. I achieved this by setting a custom variable in general.php 'craft.dev' => array( 'cache' => true, 'environmentVariables' => array(...), ) '192.168.178.20' => ...


28

Avoiding unnecessary DB queries is definitely the main thing to watch out for. Here’s an example that came up recently in support: Someone wanted to display the first 6 Matrix blocks in an entry, outputting them 2 at a time. Initially the template code looked something like this: {% for block in entry.matrixField.limit(2) %} <!-- Get the 1st two ...


19

Template performance isn't a huge worry in Craft thanks to the built-in cache tag. Even if some code is taking time to process, it can be wrapped in that tag to greatly improve performance. But to more thoroughly answer your question, the scenarios where that tag might have to be used generally revolve around the number of DB queries. Craft's relationship ...


12

Seems to be the case that Craft won't attempt to resolve these /cpresources/transforms/ URLs until the asset is actually requested, which can mess with a setup like PictureFill where there is no guarantee that the transformed assets will ever be loaded. Solution in my case was to to set 'generateTransformsBeforePageLoad' => true, in your Craft config ...


10

To be honest, those two parameters may seem to be slightly similar but provide a totally different functionality. From their documentation on search: search Only fetch entries that match a given search query. (See Searching for the syntax and > available search attributes.) Which means whatever you pass in .search(query), and there is a rather complex ...


9

Nope. Once a transform has been generated once, Craft remembers that, and saves it right in your asset source. Future page loads will get a direct URL to that generated image, so it gets loaded via your webserver (or S3, etc.) directly. No PHP involved.


9

So a few potential things to consider: You do not want to be serving static assets like Javascript, CSS, etc. out of the templates directory. I realize you're planning to put them "elsewhere", but ensure that elsewhere is in the /public/ folder, so that php, Yii, and Craft do not have to be spun up just to serve a static asset. Do not use a Craft routine/...


8

The {% cache %}, by default will cache it's contents on a per URL and per locale basis. A lot of times when we see the behavior you're seeing, that's not the desired behavior and you should be using the {% cache globally %} parameter, where Craft stores the cached segment only on a per locale basis and drastically reduces the number of rows in the database ...


8

I've just ran into this myself this morning. It looks to be related to the SmartMaps plugin doing an IP > Geo lookup using an external service. Specifically it looks like it's using this api :https://geoip.maxmind.com/geoip/v2.0/ which is hanging. Disabling the plugin fixed my loading issues.


8

For all practical purposes, no. The performance hit for images transforms happens the first time the transform is requested and generated. After that, the images are served as a normal file that your web server can serve up as quickly as any other file.


8

Regardless of the number of elements involved, Craft will return an iterable ElementCriteriaModel whenever you query for content (e.g. via craft.entries, or using relational FieldTypes like Assets, Entries or Categories). This means that even if you know that there'll only be a single element returned (e.g. when you query for a Single section entry, or have ...


8

Preview function for different devices, screen sizes and screen configurations(portrait/landscape) Yes it has live preview. However this isn't per device. You can open the entry with a secret url and then user your browser tools to check different devices Is it possible to publish only a subset of my website? Yes, each entry can be turned on or off ...


7

I can't answer your question directly as I never got even close to 300 fields yet. But even with 50 fields I had some serious slowdowns, especially when getting related entries in form of assets and such. I think you should definitely consider using the built in cache function to get good performance. In regards to that field name / instructions problem ...


7

First off: Craft stores cached content in the templatecaches table. Craft stores criteria mapping to the cached versions in templatecachecriteria. 1. Make sure Craft isn't caching too much. Originally, we were using {% cache using key craft.request.path if not craft.config.devMode %} We discovered it's critical to use the globally keyword: {% cache ...


7

Let me try to turn this into a more valuable StackExchange for others who will find it, since the original poster apparently got help and solved his problem without participating here. We can see so on the linked site, which is now running as expected for Craft, quite rapidly. What I'd like to do is suggest a less awkward way to approach his task. We can do ...


7

The performance aspect is difficult to answer. On every pageload, Craft pulls all your global sets, which can be a performance hit, especially if you have many huge, complex global sets with a lot of fields. Any Single used in place of a global could be pulled on a need-to-use basis, i.e. not on every page, although the extra call to the EntriesService would ...


6

Could you upload a "non Craft" php-file, restart the server, and check if this file also loads slow? If it does, the server has probably some kind of an issue, and you should contact your hoster. If not, try: deleting the /craft/app/storage/runtime directory. bumping up the php memory_limit. contacting P&T support from the Dashboard widget. They love ...


6

Sure... we've seen Craft installs with several hundred thousands entries/users/assets/etc. running in the wild, but there really isn't a simple answer to this question. As you pointed out, performance can be heavily dependent on the server and environment that Craft is running on, but that goes for any web application. Performance on the front-end is also ...


6

This is a great resource on improving performance as it's a multi-pronged attack: Native craft caching {% cache %} which you mentioned you have done CDN and Browser caching Varnish and other tools, including plugins like Cache Warmer I concentrated on cache as this is usually where the bottleneck seems to happen in Craft. Apologies if you've addressed all ...


6

It's a bit of a loaded question, but generally it's going to depend more on environmental limitations than anything with Craft itself. If you're on a shared host along with 200 other accounts using the same MySQL server, then you'll likely notice slowdowns sooner than later. If you're on a decent host with plenty of memory/disk/CPU available, then we've ...


6

I've been making use of macros to create a component based architecture in a recent project. I've found this way of working useful in a few different ways: Jumping around your codebase is much easier as you only have to remember what you've named your components or their parent folder to find and edit them. It keeps your main templates easier to scan. You ...


5

"Due to the amount of queries to this backend we will probably run out of its auto incremental key space." That would seem to suggest that maybe your template caching strategy should be re-visited? Are there really going to be 215 million (from a signed int) unique pieces of cached content that need to be saved? Now my question is can I override the ...


5

Update: Am I allowed to change my mind on this? :) My original answer didn't take into account storage/logo, storage/backups and anything else that a plugin might be storing in the craft/storage folder. So it's probably going to be much cleaner and safer to have CRAFT_STORAGE_PATH point to the shared file system. I would set CRAFT_STORAGE_PATH and have ...


5

If you enable devMode, you'll get code profiling information (execution times, memory used, stack traces, etc.) that you can use to debug templates with in your browser's console as well as in the craft/storage/runtime/logs folder.


5

Short yes! You can find a detailed Benchmark on http://www.lornajane.net/posts/2014/php-5-6-benchmarks. If possible i would try to update from PHP 5.4.40 direct to PHP 7. The performance from PHP 5.4 to PHP 7 is massiv. A change to PHP7 made our Craft installation twice as fast. You can find some further information here -> https://pixelandtonic.com/blog/php-...


5

If you know which years should appear, and there are no breaks in the timeline, perhaps it would make more sense to do a simple numeric loop instead... {% for year in (now.year)..2009 %} {{ year }} {% endfor %} That will count backwards from the current year to 2009.


5

Both are essentially the same query, the only thing that differs is the WHERE statement. The ID approach will always be the most efficient, since it uses the primary key index, thus finding the result faster. You could also do the first example the same way you did the second one: {% set entry = craft.entries.section('information').slug('about').first() %}...


4

I built the Cache Warmer plugin recently, which takes a blanket approach to refreshing your pages cache, by getting entries url with the .getUrl() method, and then send of batch requests to those url's. I'm currently using it together with the Cache Clear plugin, when deploying changes to our site, and it's working well. This is a very simplistic approach ...


4

MAMP isn't really tuned for performance either. And also keep in mind Time to First Byte is not the only indicator of a fast website. You should consider overall perceived time and actual download time as factors as well. CloudFlare talked about one aspect of this on their blog... for example: with Gzip compression, the web server has to wait while it ...


Only top voted, non community-wiki answers of a minimum length are eligible