Skip to content

Commit fcd3377

Browse files
committed
add initial docs regarding full page caching
1 parent c9a4007 commit fcd3377

2 files changed

Lines changed: 37 additions & 135 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
sidebar_label: CDN & Caching
3+
sidebar_position: 2
4+
title: Storefront CDN & Caching
5+
---
6+
7+
Storefront leverages many caching strategies to ensure fast performant user experiences for your end customers.
8+
9+
:::tip Use Network Domain while Building Themes
10+
Always use the store network domain `{store}.29next.store` when developing themes to bypass full page caching and preview your latest updates.
11+
:::
12+
13+
### Assets CDN
14+
15+
All merchant uploaded media assets and theme assets are loaded from our CDN for the fastest performance.
16+
17+
### Full Page Caching
18+
19+
All pages on storefront are cached for 5 minutes under the following conditions.
20+
21+
- User is Anonymous (unauthenticated).
22+
- Domain is a merchant mapped domain.
23+
- Page is not dynamic, ie `/cart/`, `/checkout/`, `/accounts/` do not use full page caching.
24+
25+
26+
### Template Caching
27+
28+
Themes use many templates ie layouts, partials, and assets when compiled together create amazing customer experiences. Templates are cached in memory to reduce database queries when compiling templates into the full html response.
29+
30+
Updating a template through the dashboard or [Theme Kit](/docs/storefront/themes/theme-kit.md) should automatically purge the cache for you to see your latest changes on the network domain, see notes above.
31+
32+
33+
:::warning
34+
There are a few cases wherein a form on the frontend needs to use a `{% csrf_token %}` field to secure submission to the backend. The platform core JS will automatically replace `{% csrf_token %}` that are in cached versions of pages to ensure the forms still work.
35+
36+
**It is advisable to not implement custom templates that require `{% csrf_token %}`, we recommend to [Storefront API](/docs/storefront/api.md) instead.**
37+
:::

docs/storefront/themes/templates/objects.md

Lines changed: 0 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,6 @@ The current session active request context.
288288

289289
| Property | Type | Description |
290290
| ----- | ------ | ------ |
291-
| `user` | Object | Current authenticated user, see [user](#user). |
292-
| `cart` | Object | Current cart for the current session, see [cart](#cart). |
293291
| `get_host` | String | Current host domain. |
294292
| `path` | String | Current url path. |
295293
| `COUNTRY_CODE` | String | Current active geo country code, see [geo](#geo). |
@@ -446,55 +444,6 @@ Store branding properties accessed through the [store](#store) object to leverag
446444
| `primary_color` | String | Store branding primary color, returns a HEX code. |
447445
| `accent_color` | String | Store branding accent color, returns a HEX code. |
448446

449-
### cart
450-
451-
Cart object that contains all of the information about the users currently active cart.
452-
453-
| Property | Type | Description |
454-
| ----- | ------ | ------ |
455-
| `all_lines` | List | Returns a list of all cart line items. |
456-
| `num_items` | Integer | Returns the count of the items in the cart. |
457-
| `is_empty` | Boolean | Returns true/false if the cart is empty or not. |
458-
| `currency` | Object | Returns the currency of the cart as an object, see [currency](#currency). |
459-
| `vouchers` | List | Returns a list of vouchers attached to the cart, see [voucher](#voucher). |
460-
| `is_tax_known` | Boolean | Returns true/false if the cart tax is known yet or not. |
461-
| `total_incl_tax` | String | Returns the cart total including tax.|
462-
| `total_excl_tax` | String | Returns the cart total excluding tax.|
463-
464-
465-
<details>
466-
<summary>Example Usage</summary>
467-
<div>
468-
469-
```django
470-
<script>
471-
dataLayer.push({ ecommerce: null });
472-
dataLayer.push({
473-
event: 'begin_checkout',
474-
ecommerce: {
475-
currency: '{{ cart.currency }}',
476-
value: '{{ cart.total_incl_tax }}',
477-
coupon: '{{ cart.vouchers.first.code }}',
478-
items: [
479-
{% for line in cart.all_lines %}
480-
{
481-
index: {{ forloop.counter0 }},
482-
item_id: '{{ line.product.id|escapejs }}',
483-
item_name: '{{ line.product.get_title|escapejs }}',
484-
item_brand: '{{ store.name|escapejs }}',
485-
item_category: '{{ line.product.categories.first.name|safe }}',
486-
price: '{{ line.unit_price_incl_tax_incl_discount|unlocalize|escapejs }}',
487-
quantity: {{ line.quantity | escapejs }}
488-
}{% if not forloop.last %}, {% endif %}
489-
{% endfor %}
490-
]
491-
}
492-
});
493-
</script>
494-
```
495-
496-
</div>
497-
</details>
498447

499448
### currency
500449

@@ -618,76 +567,8 @@ Storefront Menus can be up to 3 levels, ensure your custom menu supports 2 neste
618567
| `name` | String | Represents the display name of the current menu item. |
619568
| `url` | String | Denotes the URL path for the menu item's href link. |
620569

621-
### order
622570

623-
Order object available on the order confirmation view, typically used in tandem with javascript conversion snippets through apps or custom theme implementations, see example usage below. Only available in the `confirmation` step in the `checkout/checkout.html` template, see [Checkout Customization](/docs/storefront/themes/guides/checkout.md).
624571

625-
<details>
626-
<summary>Example Usage</summary>
627-
<div>
628-
629-
```django
630-
<script>
631-
dataLayer.push({ ecommerce: null });
632-
dataLayer.push({
633-
event: 'purchase',
634-
ecommerce: {
635-
transaction_id: '{{ order.number|escapejs }}',
636-
value: {{ order.total_incl_tax | unlocalize | escapejs }},
637-
tax: {{ order.total_tax|unlocalize|escapejs }},
638-
shipping: '{{ order.shipping_incl_tax|unlocalize|escapejs }}',
639-
currency: '{{ order.currency|escapejs }}',
640-
coupon: '{% if order.voucherapplication_set.first.voucher.code %}{{ order.voucherapplication_set.first.voucher.code }}{% endif %}',
641-
items: [
642-
{% for line in order.lines.all %}
643-
{
644-
index: {{ forloop.counter0 }},
645-
item_id: '{{ line.product.id|escapejs }}',
646-
item_name: '{{ line.title|escapejs }}',
647-
affiliation: '{{ store_name|escapejs }}',
648-
category: '{{ line.product.categories.first|default:'Uncategorised'|escapejs }}',
649-
price: '{{ line.unit_price_incl_tax_incl_discount|unlocalize|escapejs }}',
650-
quantity: {{ line.quantity | escapejs }}
651-
}{% if not forloop.last %}, {% endif %}
652-
{% endfor %}
653-
]
654-
}
655-
});
656-
</script>
657-
```
658-
659-
</div>
660-
</details>
661-
662-
663-
| Property | Type | Description |
664-
| ----- | ------ | ------ |
665-
| `number` | String | Order number. |
666-
| `currency` | String | Order currency. |
667-
| `lines` | List | List of order line items, see [order line](#order-line). |
668-
| `user` | Object | The order customer, see [user](#user). |
669-
| `total_excl_tax` | String | Order total excluding tax. |
670-
| `total_incl_tax` | String | Order total including tax. |
671-
| `total_tax` | String | Order total tax. |
672-
| `shipping_incl_tax` | String | Order shipping including tax. |
673-
| `shipping_excl_tax` | String | Order shipping excluding tax. |
674-
| `voucherapplication_set` | List | Order voucher discounts applied, see [voucher](#voucher). |
675-
| `shipping_address` | Object | Order shipping address, see [address](#address). |
676-
| `billing_address` | Object | Order billing address, see [address](#address). |
677-
678-
679-
### order line
680-
681-
Order line object details accessed through an order. See [order](#order) for example usage.
682-
683-
| Property | Type | Description |
684-
| ----- | ------ | ------ |
685-
| `product` | Object | Line item product, see [product](#product). |
686-
| `title` | String | The order line title, full product name at time of sale. |
687-
| `quantity` | String | Product quantity. |
688-
| `unit_price_incl_tax_incl_discount` | String | Per unit price including tax, including discounts. |
689-
| `unit_price_excl_tax` | String | Per unit price excluding tax. |
690-
| `unit_price_incl_tax` | String | Per unit price including tax. |
691572

692573
### page
693574

@@ -833,22 +714,6 @@ Product review object.
833714
| `user` | Object | The customer that created the review, see [user](#user). |
834715

835716

836-
### user
837-
838-
User in storefront context is the same as "customer".
839-
840-
| Property | Type | Description |
841-
| ----- | ------ | ------ |
842-
| `id` | String | Customer's unique id. |
843-
| `first_name` | String | Customer's first name. |
844-
| `last_name` | String | Customer's last name. |
845-
| `email` | String | Customer's email address. |
846-
| `phone_number` | String | Customer's phone number in e.164 format. |
847-
| `language` | String | Customer's preferred communication language. |
848-
| `accepts_marketing` | String | Wether or not the customer accepts marketing communications. |
849-
| `ip` | String | Customer's most recently used IP address. |
850-
| `user_agent` | String | Customer's most recently used user agent String. |
851-
852717
### voucher
853718

854719
Voucher object.

0 commit comments

Comments
 (0)