# E-Commerce Platform Templates

> Ready-to-use Trident configurations for Magento 2, WooCommerce, Shopware 6, PrestaShop, Sylius, Shopify, Medusa, and Saleor.

Ready-to-use Trident configurations for popular e-commerce platforms. Each template includes platform-specific cache rules, tag handling, and bypass logic for dynamic pages like carts and checkouts.

<Admonition type="tip" title="How to use these templates">
Copy the JSON configuration for your platform to `/etc/trident/trident.json`, update the backend address to match your application server, and restart Trident.
</Admonition>

---

## Magento 2

Magento 2 is a PHP-based e-commerce platform with a large cache footprint. This template is tuned for its architecture: a **4 GB cache** to handle Magento's extensive catalog pages, **GraphQL query caching** (GET only) to accelerate headless storefronts, **backend connection protection** to keep PHP-FPM stable during flash sales, and native **`X-Magento-Tags`** header integration for surgical cache invalidation. Static and media assets get long TTLs, while admin, checkout, customer, and REST API routes bypass the cache entirely. Launch mode support is included for zero-downtime deployments.

```json
{
  "server": {
    "listen": ["0.0.0.0:8080"],
    "admin_listen": "127.0.0.1:9100",
    "metrics_listen": "0.0.0.0:9191"
  },
  "cache": {
    "max_size": "4GB",
    "default_ttl": "1h",
    "stale_while_revalidate": "60s",
    "stale_if_error": "300s",
    "tags": {
      "enabled": true,
      "header_name": "X-Magento-Tags",
      "separator": ","
    }
  },
  "backends": {
    "magento": {
      "host": "127.0.0.1",
      "port": 9000,
      "health": {
        "enabled": true,
        "path": "/health_check.php",
        "interval": "10s",
        "timeout": "5s",
        "threshold_healthy": 2,
        "threshold_unhealthy": 3
      },
      "protection": {
        "enabled": true,
        "max_connections": 50,
        "queue_size": 100,
        "queue_timeout": "30s"
      }
    }
  },
  "directors": {
    "default": {
      "backends": ["magento"],
      "strategy": "round_robin"
    }
  },
  "rules": [
    {
      "name": "magento_static",
      "match": { "path_prefix": "/static/" },
      "action": { "cache": true, "ttl": "30d" }
    },
    {
      "name": "magento_media",
      "match": { "path_prefix": "/media/" },
      "action": { "cache": true, "ttl": "7d" }
    },
    {
      "name": "magento_admin",
      "match": { "path_prefix": "/admin" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "magento_checkout",
      "match": { "path_prefix": "/checkout" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "magento_customer",
      "match": { "path_prefix": "/customer" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "magento_api",
      "match": { "path_prefix": "/rest/" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "magento_graphql",
      "match": { "path": "/graphql" },
      "action": { "cache": true, "ttl": "5m", "methods": ["GET"] }
    }
  ],
  "launch": {
    "enabled": false,
    "persist_state": true,
    "state_file": "/var/lib/trident/launch-state.json",
    "max_urls": 10000
  }
}
```

---

## WooCommerce

WooCommerce runs on WordPress and PHP-FPM. This template provides a **2 GB cache** with rules tailored to the WordPress directory layout: long TTLs for `wp-content` and `wp-includes` assets, and cache bypass for `wp-admin`, `wp-login.php`, and AJAX endpoints. WooCommerce-specific paths like `/cart`, `/checkout`, and `/my-account` are passed through uncached. Two cookie-based rules handle **logged-in user detection** via the `wordpress_logged_in_*` cookie and **active cart detection** via the `woocommerce_cart_hash` cookie, ensuring personalized or cart-containing requests always reach the origin.

```json
{
  "server": {
    "listen": ["0.0.0.0:8080"],
    "admin_listen": "127.0.0.1:9100",
    "metrics_listen": "0.0.0.0:9191"
  },
  "cache": {
    "max_size": "2GB",
    "default_ttl": "1h",
    "stale_while_revalidate": "60s",
    "stale_if_error": "300s",
    "tags": {
      "enabled": true,
      "header_name": "X-Cache-Tags",
      "separator": ","
    }
  },
  "backends": {
    "wordpress": {
      "host": "127.0.0.1",
      "port": 9000
    }
  },
  "directors": {
    "default": {
      "backends": ["wordpress"],
      "strategy": "round_robin"
    }
  },
  "rules": [
    {
      "name": "wp_static",
      "match": { "path_prefix": "/wp-content/" },
      "action": { "cache": true, "ttl": "30d" }
    },
    {
      "name": "wp_includes",
      "match": { "path_prefix": "/wp-includes/" },
      "action": { "cache": true, "ttl": "30d" }
    },
    {
      "name": "wp_admin",
      "match": { "path_prefix": "/wp-admin" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "wp_login",
      "match": { "path": "/wp-login.php" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "woo_cart",
      "match": { "path_prefix": "/cart" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "woo_checkout",
      "match": { "path_prefix": "/checkout" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "woo_my_account",
      "match": { "path_prefix": "/my-account" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "woo_api",
      "match": { "path_prefix": "/wp-json/wc/" },
      "action": { "cache": true, "ttl": "5m", "methods": ["GET"] }
    },
    {
      "name": "wp_ajax",
      "match": { "path": "/wp-admin/admin-ajax.php" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "logged_in_users",
      "match": { "cookie_regex": "wordpress_logged_in_.*" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "woo_cart_cookie",
      "match": { "cookie_regex": "woocommerce_cart_hash" },
      "action": { "cache": false, "pass": true }
    }
  ]
}
```

---

## Shopware 6

Shopware 6 is a Symfony-based e-commerce platform. This template uses a **2 GB cache** and is configured for Shopware's asset layout: `/bundles/` for compiled plugin assets, `/theme/` for storefront themes, and `/media/` for product images. The **Store API** (`/store-api/`) is cached for GET requests with a short TTL, while the admin API (`/api/`) is always passed through. A key detail is the **space-separated cache tag format** -- Shopware uses spaces rather than commas as the tag separator in the `X-Cache-Tags` header.

```json
{
  "server": {
    "listen": ["0.0.0.0:8080"],
    "admin_listen": "127.0.0.1:9100",
    "metrics_listen": "0.0.0.0:9191"
  },
  "cache": {
    "max_size": "2GB",
    "default_ttl": "1h",
    "stale_while_revalidate": "60s",
    "stale_if_error": "300s",
    "tags": {
      "enabled": true,
      "header_name": "X-Cache-Tags",
      "separator": " "
    }
  },
  "backends": {
    "shopware": {
      "host": "127.0.0.1",
      "port": 8000
    }
  },
  "directors": {
    "default": {
      "backends": ["shopware"],
      "strategy": "round_robin"
    }
  },
  "rules": [
    {
      "name": "shopware_static",
      "match": { "path_prefix": "/bundles/" },
      "action": { "cache": true, "ttl": "30d" }
    },
    {
      "name": "shopware_theme",
      "match": { "path_prefix": "/theme/" },
      "action": { "cache": true, "ttl": "30d" }
    },
    {
      "name": "shopware_media",
      "match": { "path_prefix": "/media/" },
      "action": { "cache": true, "ttl": "7d" }
    },
    {
      "name": "shopware_admin",
      "match": { "path_prefix": "/admin" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "shopware_api",
      "match": { "path_prefix": "/api/" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "shopware_store_api",
      "match": { "path_prefix": "/store-api/" },
      "action": { "cache": true, "ttl": "5m", "methods": ["GET"] }
    },
    {
      "name": "shopware_checkout",
      "match": { "path_prefix": "/checkout" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "shopware_account",
      "match": { "path_prefix": "/account" },
      "action": { "cache": false, "pass": true }
    }
  ]
}
```

---

## PrestaShop

PrestaShop is a PHP-based e-commerce platform with a **2 GB cache** configuration. Static assets are served from `/themes/` and `/modules/` with long TTLs, while product images under `/img/` get a 7-day TTL. A distinguishing feature of this template is the **regex-based admin path rule** (`/admin[a-z0-9]*/`) -- PrestaShop randomizes its admin directory name during installation for security, so a static prefix match will not work. Cart, order, my-account, and API routes all bypass the cache.

```json
{
  "server": {
    "listen": ["0.0.0.0:8080"],
    "admin_listen": "127.0.0.1:9100",
    "metrics_listen": "0.0.0.0:9191"
  },
  "cache": {
    "max_size": "2GB",
    "default_ttl": "1h",
    "stale_while_revalidate": "60s",
    "stale_if_error": "300s",
    "tags": {
      "enabled": true,
      "header_name": "X-Cache-Tags",
      "separator": ","
    }
  },
  "backends": {
    "prestashop": {
      "host": "127.0.0.1",
      "port": 9000
    }
  },
  "directors": {
    "default": {
      "backends": ["prestashop"],
      "strategy": "round_robin"
    }
  },
  "rules": [
    {
      "name": "ps_themes",
      "match": { "path_prefix": "/themes/" },
      "action": { "cache": true, "ttl": "30d" }
    },
    {
      "name": "ps_modules",
      "match": { "path_prefix": "/modules/" },
      "action": { "cache": true, "ttl": "30d" }
    },
    {
      "name": "ps_img",
      "match": { "path_prefix": "/img/" },
      "action": { "cache": true, "ttl": "7d" }
    },
    {
      "name": "ps_admin",
      "match": { "path_regex": "/admin[a-z0-9]*/" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "ps_cart",
      "match": { "path_prefix": "/cart" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "ps_order",
      "match": { "path_prefix": "/order" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "ps_my_account",
      "match": { "path_prefix": "/my-account" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "ps_api",
      "match": { "path_prefix": "/api/" },
      "action": { "cache": false, "pass": true }
    }
  ]
}
```

---

## Sylius

Sylius is built on Symfony and exposes a REST API alongside its storefront. This template provides a **2 GB cache** with rules for Symfony's compiled `/assets/` directory (30-day TTL) and `/media/` uploads (7-day TTL). The Sylius REST API under `/api/` is **cached for GET requests** with a 5-minute TTL, making it suitable for headless storefronts that read product data through the API. Admin, cart, checkout, and account routes bypass the cache entirely.

```json
{
  "server": {
    "listen": ["0.0.0.0:8080"],
    "admin_listen": "127.0.0.1:9100",
    "metrics_listen": "0.0.0.0:9191"
  },
  "cache": {
    "max_size": "2GB",
    "default_ttl": "1h",
    "stale_while_revalidate": "60s",
    "stale_if_error": "300s",
    "tags": {
      "enabled": true,
      "header_name": "X-Cache-Tags",
      "separator": ","
    }
  },
  "backends": {
    "sylius": {
      "host": "127.0.0.1",
      "port": 8000
    }
  },
  "directors": {
    "default": {
      "backends": ["sylius"],
      "strategy": "round_robin"
    }
  },
  "rules": [
    {
      "name": "sylius_assets",
      "match": { "path_prefix": "/assets/" },
      "action": { "cache": true, "ttl": "30d" }
    },
    {
      "name": "sylius_media",
      "match": { "path_prefix": "/media/" },
      "action": { "cache": true, "ttl": "7d" }
    },
    {
      "name": "sylius_admin",
      "match": { "path_prefix": "/admin" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "sylius_api",
      "match": { "path_prefix": "/api/" },
      "action": { "cache": true, "ttl": "5m", "methods": ["GET"] }
    },
    {
      "name": "sylius_cart",
      "match": { "path_prefix": "/cart" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "sylius_checkout",
      "match": { "path_prefix": "/checkout" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "sylius_account",
      "match": { "path_prefix": "/account" },
      "action": { "cache": false, "pass": true }
    }
  ]
}
```

---

## Shopify Headless

This template is for **headless Shopify** storefronts built with Next.js, Hydrogen, or similar frameworks. Unlike traditional server-rendered platforms, the backend here is your Node.js storefront application (port 3000), not Shopify itself. The cache is sized at **1 GB** with a shorter **15-minute default TTL** to keep product data fresh. Next.js build assets under `/_next/static/` and optimized images under `/_next/image` get long TTLs. Product and collection pages are cached with tag support for targeted invalidation via webhooks. Cart, checkout, account, and custom API routes bypass the cache.

```json
{
  "server": {
    "listen": ["0.0.0.0:8080"],
    "admin_listen": "127.0.0.1:9100",
    "metrics_listen": "0.0.0.0:9191"
  },
  "cache": {
    "max_size": "1GB",
    "default_ttl": "15m",
    "stale_while_revalidate": "120s",
    "stale_if_error": "300s",
    "tags": {
      "enabled": true,
      "header_name": "X-Cache-Tags",
      "separator": ","
    }
  },
  "backends": {
    "storefront": {
      "host": "127.0.0.1",
      "port": 3000
    }
  },
  "directors": {
    "default": {
      "backends": ["storefront"],
      "strategy": "round_robin"
    }
  },
  "rules": [
    {
      "name": "storefront_static",
      "match": { "path_prefix": "/_next/static/" },
      "action": { "cache": true, "ttl": "30d" }
    },
    {
      "name": "storefront_images",
      "match": { "path_prefix": "/_next/image" },
      "action": { "cache": true, "ttl": "7d" }
    },
    {
      "name": "storefront_api",
      "match": { "path_prefix": "/api/" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "storefront_cart",
      "match": { "path_prefix": "/cart" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "storefront_checkout",
      "match": { "path_prefix": "/checkout" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "storefront_account",
      "match": { "path_prefix": "/account" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "storefront_products",
      "match": { "path_prefix": "/products/" },
      "action": { "cache": true, "ttl": "15m" }
    },
    {
      "name": "storefront_collections",
      "match": { "path_prefix": "/collections/" },
      "action": { "cache": true, "ttl": "15m" }
    }
  ]
}
```

---

## Medusa.js

Medusa.js is an API-first, headless commerce engine built on Node.js. This template uses a **1 GB cache** with a **30-minute default TTL**. The Store API endpoints for products, collections, and regions are cached for GET requests with varying TTLs -- regions get a longer 1-hour TTL since they change infrequently. Cart, checkout, customer, and order endpoints are always passed through to the origin since they carry session-specific data. The admin dashboard is bypassed entirely.

```json
{
  "server": {
    "listen": ["0.0.0.0:8080"],
    "admin_listen": "127.0.0.1:9100",
    "metrics_listen": "0.0.0.0:9191"
  },
  "cache": {
    "max_size": "1GB",
    "default_ttl": "30m",
    "stale_while_revalidate": "60s",
    "stale_if_error": "300s",
    "tags": {
      "enabled": true,
      "header_name": "X-Cache-Tags",
      "separator": ","
    }
  },
  "backends": {
    "medusa": {
      "host": "127.0.0.1",
      "port": 9000
    }
  },
  "directors": {
    "default": {
      "backends": ["medusa"],
      "strategy": "round_robin"
    }
  },
  "rules": [
    {
      "name": "medusa_admin",
      "match": { "path_prefix": "/admin" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "medusa_store_products",
      "match": { "path_prefix": "/store/products" },
      "action": { "cache": true, "ttl": "15m", "methods": ["GET"] }
    },
    {
      "name": "medusa_store_collections",
      "match": { "path_prefix": "/store/collections" },
      "action": { "cache": true, "ttl": "15m", "methods": ["GET"] }
    },
    {
      "name": "medusa_store_regions",
      "match": { "path_prefix": "/store/regions" },
      "action": { "cache": true, "ttl": "1h", "methods": ["GET"] }
    },
    {
      "name": "medusa_cart",
      "match": { "path_prefix": "/store/carts" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "medusa_checkout",
      "match": { "path_prefix": "/store/checkout" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "medusa_customers",
      "match": { "path_prefix": "/store/customers" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "medusa_orders",
      "match": { "path_prefix": "/store/orders" },
      "action": { "cache": false, "pass": true }
    }
  ]
}
```

---

## Saleor

Saleor is a GraphQL-first e-commerce platform built on Django. This template uses a **1 GB cache** with a **15-minute default TTL**. The key distinction is how GraphQL is handled: **GET requests** to `/graphql/` are cached (these are typically persisted queries or simple reads), while **POST requests** are passed through since they may contain mutations or complex queries that are not safe to cache. Static assets and media get long TTLs. The Saleor dashboard and plugin webhook endpoints bypass the cache.

```json
{
  "server": {
    "listen": ["0.0.0.0:8080"],
    "admin_listen": "127.0.0.1:9100",
    "metrics_listen": "0.0.0.0:9191"
  },
  "cache": {
    "max_size": "1GB",
    "default_ttl": "15m",
    "stale_while_revalidate": "60s",
    "stale_if_error": "300s",
    "tags": {
      "enabled": true,
      "header_name": "X-Cache-Tags",
      "separator": ","
    }
  },
  "backends": {
    "saleor": {
      "host": "127.0.0.1",
      "port": 8000
    }
  },
  "directors": {
    "default": {
      "backends": ["saleor"],
      "strategy": "round_robin"
    }
  },
  "rules": [
    {
      "name": "saleor_graphql_get",
      "match": { "path": "/graphql/", "methods": ["GET"] },
      "action": { "cache": true, "ttl": "15m" }
    },
    {
      "name": "saleor_graphql_post",
      "match": { "path": "/graphql/", "methods": ["POST"] },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "saleor_media",
      "match": { "path_prefix": "/media/" },
      "action": { "cache": true, "ttl": "7d" }
    },
    {
      "name": "saleor_static",
      "match": { "path_prefix": "/static/" },
      "action": { "cache": true, "ttl": "30d" }
    },
    {
      "name": "saleor_dashboard",
      "match": { "path_prefix": "/dashboard/" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "saleor_plugins",
      "match": { "path_prefix": "/plugins/" },
      "action": { "cache": false, "pass": true }
    }
  ]
}
```
