Browse Source

Performance docs - Mention the importance of passing `request` and `current_site` to `get_url`

- Co-authored-by: Andy Babic <ababic@users.noreply.github.com>
Jake Howard 2 years ago
parent
commit
c6afb0069d
3 changed files with 10 additions and 0 deletions
  1. 1 0
      CHANGELOG.txt
  2. 8 0
      docs/advanced_topics/performance.md
  3. 1 0
      docs/releases/4.2.md

+ 1 - 0
CHANGELOG.txt

@@ -11,6 +11,7 @@ Changelog
  * Upgrade to Node 18 for frontend build tooling (LB (Ben) Johnston)
  * Officially recommend `fnm` over `nvm` in development documentation (LB (Ben) Johnston)
  * Test assertion util `WagtailPageTestCase.assertCanCreate` now supports the kwarg `publish=True` to check publish redirection (Harry Percival, Akua Dokua Asiedu)
+ * Mention the importance of passing `request` and `current_site` to `get_url` on the [performance](performance) documentation page (Jake Howard)
  * Fix: Make sure workflow timeline icons are visible in high-contrast mode (Loveth Omokaro)
  * Fix: Ensure authentication forms (login, password reset) have a visible border in Windows high-contrast mode (Loveth Omokaro)
  * Fix: Ensure visual consistency between buttons and links as buttons in Windows high-contrast mode (Albina Starykova)

+ 8 - 0
docs/advanced_topics/performance.md

@@ -58,6 +58,14 @@ 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
+
+To fully resolve the URL of a page, Wagtail requires information from a few different sources.
+
+The methods used to get the URL of a `Page` such as `Page.get_url` and `Page.get_full_url` optionally accept extra arguments for `request` and `current_site`. Passing these arguments enable much of underlying site-level URL information to be reused for the current request. In situations such as navigation menu generation, plus any links that appear in page content, providing `request` or `current_site` can result in a drastic reduction in the number of cache or database queries your site will generate for a given page load.
+
+When using the [`{% pageurl %}`](page_urls) template tag, the request is automatically passed in, so no further optimisation is needed.
+
 ### 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/).

+ 1 - 0
docs/releases/4.2.md

@@ -21,6 +21,7 @@ depth: 1
  * Test assertion [`WagtailPageTestCase.assertCanCreate`](testing_reference) now supports the kwarg `publish=True` to check publish redirection (Harry Percival, Akua Dokua Asiedu)
  * Upgrade to Node 18 for frontend build tooling (LB (Ben) Johnston)
  * Officially recommend `fnm` over `nvm` in development documentation (LB (Ben) Johnston)
+ * Mention the importance of passing `request` and `current_site` to `get_url` on the [performance](performance) documentation page (Jake Howard)
 
 ### Bug fixes