39 votes
Accepted

What are the best practices for using the {% cache %} tag?

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 ...
user avatar
31 votes

What are the best practices for using the {% cache %} tag?

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 ...
user avatar
  • 35.8k
29 votes
Accepted

What are the most common template performance gotchas to avoid?

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, ...
user avatar
19 votes

What are the most common template performance gotchas to avoid?

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 ...
user avatar
12 votes
Accepted

Caching not working on page with asynchronously loaded asset transforms

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 ...
user avatar
  • 815
10 votes
Accepted

Using “search” vs. “relatedTo” in a template

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 ...
user avatar
9 votes
Accepted

Can image transforms decrease performance?

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 ...
user avatar
9 votes
Accepted

Creating partials outside of the templates folder

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 ...
user avatar
8 votes
Accepted

Long 'Deleting stale template caches'

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 ...
user avatar
  • 66.4k
8 votes

Huge Latency In Pre-prod Environment

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:/...
user avatar
8 votes

Can image transforms decrease performance?

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 ...
user avatar
  • 66.4k
8 votes

Globals versus Singles

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 ...
user avatar
8 votes
Accepted

Which is best practice, SET or FOR?

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, ...
user avatar
8 votes
Accepted

Does Craft CMS support these features?

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 ...
user avatar
  • 1,907
7 votes

Will having large numbers of Fields decrease site performance?

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 ...
user avatar
  • 35.8k
7 votes

How can I mitigate caching performance issues with Craft?

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. ...
user avatar
  • 281
7 votes

Server respond is very long (25s). Is there a way to optimize the perfomance?

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 ...
user avatar
  • 1,697
6 votes
Accepted

Huge Latency In Pre-prod Environment

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 ...
user avatar
  • 8,316
6 votes
Accepted

Can Craft handle thousands of entries and high traffic?

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, ...
user avatar
  • 66.4k
6 votes

How to improve unexpectedly poor Craft performance?

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, ...
user avatar
  • 173
6 votes

How many entries could the Craft database hold before it slows down?

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 ...
user avatar
  • 66.4k
6 votes

Creating partials outside of the templates folder

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 ...
user avatar
  • 3,833
5 votes
Accepted

Is there a way to override the template caching system?

"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? ...
user avatar
  • 66.4k
5 votes

Load balancing nodes configuration (3 Craft nodes behind F5 Big-IP)

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 ...
user avatar
  • 66.4k
5 votes
Accepted

Measuring Template Performance

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 ...
user avatar
  • 66.4k
5 votes
Accepted

Are there any advantages of updating from PHP 5.4.40 to 5.6?

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 ...
user avatar
  • 1,317
5 votes
Accepted

A more economical method of building an archive menu?

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 }...
user avatar
  • 23.6k
5 votes

Which is best practice, SET or FOR?

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 ...
user avatar
  • 396
4 votes
Accepted

Cache invalidation to automatically update all cached template content?

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'...
user avatar
  • 2,957
4 votes

Slightly-slow page load for blank page

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 ...
user avatar
  • 6,467

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