Igor
Cheledinov

Drupal Performance tips
What is performance?
"for web"

As user I want fast:
- Loading
- Surfing between pages
- Animation
- Video
- Reaction
- Interaction
- UI/UX
- ALL
Server
Network
Client

Tools to detect performance issues:
- MySQL slow log
- XHprof
- Web Developer tools
- NewRelic
- Blackfire
- ...
Bandwidth optimization

Drupal 8 Configuration

Additional modules
- Advanced CSS/JS Aggregation
- Blazy
- Image Lazyloader
- Lazy-load
- CDN
Drupal 8 CDN settings

Parallelize downloads across hostnames

HTTP Caching
- Cache-Control: public
- Etag
- Last-Modified
- Expires
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Caching in Drupal 8

Core caching techniques of Drupal 8

Internal Page Cache

Internal Page Cache works for anonymous user



Internal Dynamic Page Cache
- Partial caching
- Fragment Caching


Cache API

Cacheability metadata
- Сache tags
- Сache contexts
- Сache max-age
'#cache' => [
'contexts' => ['languages', 'timezone', 'user'],
'tags' => ['node:5', 'user:6'],
'max-age' => Cache::PERMANENT,
],Cache max-age
Cache max-age = time dependencies
Cache max-age is analogous to HTTP's Cache-Control header's max-age directive
Example
# Example for most render arrays:
$build['#cache']['max-age'] = 0;
# Example in a function:
\Drupal::cache()->set('my_cache_item', $school_list, REQUEST_TIME + (86400));
Сache contexts
Cache contexts = (request) context dependencies
Cache contexts are analogous to HTTP's Vary header.
Сache tags
Cache tags = data dependencies
Cache tags describe dependencies on data managed by Drupal
Example
# Set
$cache_backend->set(
$cid, $data, Cache::PERMANENT, ['node:5', 'user:7']
);
# Invalidate
cache_tags.invalidator:invalidateTags()
Headers:
X-Drupal-Cache-Tags
Cache-Tag
Integration with reverse proxies and CDN
- Varnish
- CloudFlare
- Fastly
- KeyCDN
- Akamai
BigPipe

Auto-placeholdering
#lazy_builder

Example
$build[$id]['links'] = array(
'#lazy_builder' => [
'comment.lazy_builders:renderLinks',
[
$entity->id(),
$view_mode,
$entity->language()->getId(),
!empty($entity->in_preview),
],
],
'#create_placeholder' => TRUE,
);
BigPipe

Edge Side Includes

<esi src="

External cache


ESI module for Drupal 8
?

Links


Thank you

Drupal Performance tips: configs optimization, partial caching, BigPipe and ESI
By chilic
Drupal Performance tips: configs optimization, partial caching, BigPipe and ESI
- 235