Przeglądaj źródła

Performance page cleanup (#9362)

* Clean up the performance page structure

Many of the sections mentioned here will improve performance for much more than just the editor experience.

* Link to Django's performance page
Jake Howard 2 lat temu
rodzic
commit
66421dac13
1 zmienionych plików z 9 dodań i 29 usunięć
  1. 9 29
      docs/advanced_topics/performance.md

+ 9 - 29
docs/advanced_topics/performance.md

@@ -2,11 +2,9 @@
 
 Wagtail is designed for speed, both in the editor interface and on the front-end, but if you want even better performance or you need to handle very high volumes of traffic, here are some tips on eking out the most from your installation.
 
-## Editor interface
-
 We have tried to minimise external dependencies for a working installation of Wagtail, in order to make it as simple as possible to get going. However, a number of default settings can be configured for better performance:
 
-### Cache
+## Cache
 
 We recommend [Redis](https://redis.io/) as a fast, persistent cache. Install Redis through your package manager (on Debian or Ubuntu: `sudo apt-get install redis-server`), add `django-redis` to your `requirements.txt`, and enable it as a cache backend:
 
@@ -58,7 +56,7 @@ Another side benefit is it prevents errors during conversation from causing page
 
 The same can be achieved in Python using [`generate_image_url`](dynamic_image_urls).
 
-### Page URLs
+## Page URLs
 
 To fully resolve the URL of a page, Wagtail requires information from a few different sources.
 
@@ -66,41 +64,19 @@ The methods used to get the URL of a `Page` such as `Page.get_url` and `Page.get
 
 When using the [`{% pageurl %}`](page_urls) template tag, the request is automatically passed in, so no further optimisation is needed.
 
-### Search
+## Search
 
 Wagtail has strong support for [Elasticsearch](https://www.elastic.co) - both in the editor interface and for users of your site - but can fall back to a database search if Elasticsearch isn't present. Elasticsearch is faster and more powerful than the Django ORM for text search, so we recommend installing it or using a hosted service like [Searchly](http://www.searchly.com/).
 
 For details on configuring Wagtail for Elasticsearch, see [](wagtailsearch_backends_elasticsearch).
 
-### Database
+## Database
 
 Wagtail is tested on PostgreSQL, SQLite and MySQL. It may work on some third-party database backends as well, but this is not guaranteed. We recommend PostgreSQL for production use.
 
-### Templates
-
-The overhead from reading and compiling templates adds up. Django wraps its default loaders with [cached template loader](django.template.loaders.cached.Loader) which stores the compiled `Template` in memory and returns it for subsequent requests. The cached loader is automatically enabled when `DEBUG` is `False`. If you are using custom loaders, update your settings to use it:
-
-```python
-TEMPLATES = [{
-    'BACKEND': 'django.template.backends.django.DjangoTemplates',
-    'DIRS': [os.path.join(BASE_DIR, 'templates')],
-    'OPTIONS': {
-        'loaders': [
-            ('django.template.loaders.cached.Loader', [
-                'django.template.loaders.filesystem.Loader',
-                'django.template.loaders.app_directories.Loader',
-                'path.to.custom.Loader',
-            ]),
-        ],
-    },
-}]
-```
-
-## Public users
-
 (caching_proxy)=
 
-### Caching proxy
+## Caching proxy
 
 To support high volumes of traffic with excellent response times, we recommend a caching proxy. Both [Varnish](https://varnish-cache.org/) and [Squid](http://www.squid-cache.org/) have been tested in production. Hosted proxies like [Cloudflare](https://www.cloudflare.com/) should also work well.
 
@@ -111,3 +87,7 @@ Wagtail supports automatic cache invalidation for Varnish/Squid. See [](frontend
 For some images, it may be beneficial to lazy load images, so the rest of the page can continue to load. It can be configured site-wide [](adding_default_attributes_to_images) or per-image [](image_tag_alt). For more details you can read about the [`loading='lazy'` attribute](https://developer.mozilla.org/en-US/docs/Web/Performance/Lazy_loading#images_and_iframes) and the [`'decoding='async'` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-decoding) or this [web.dev article on lazy loading images](https://web.dev/lazy-loading-images/).
 
 This optimisation is already handled for you for images in the admin site.
+
+## Django
+
+Wagtail is built on Django. Many of the [performance tips](https://docs.djangoproject.com/en/stable/topics/performance/) set out by Django are also applicable to Wagtail.