16 min readMar 29, 2026by jakub

Web Framework Templates

Ready-to-use Trident configurations for popular web frameworks. Each template includes framework-specific cache rules, static asset handling, and bypass logic for authentication and admin routes.

How to use these templates

Copy the JSON configuration for your framework to /etc/trident/trident.json, update the backend address to match your application server, and restart Trident.


Laravel

Laravel is a PHP framework that uses Vite for frontend asset bundling. This template caches Vite build assets and storage files with long TTLs, bypasses Livewire real-time component requests and Sanctum token-based authentication routes, caches API endpoints (GET only) with a short TTL, and skips the cache entirely for authenticated users detected via the laravel_session cookie. Login, registration, dashboard, and admin panel routes all pass through uncached to ensure correct session handling.

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": {
    "laravel": {
      "host": "127.0.0.1",
      "port": 8000
    }
  },
  "directors": {
    "default": {
      "backends": ["laravel"],
      "strategy": "round_robin"
    }
  },
  "rules": [
    {
      "name": "laravel_assets",
      "match": { "path_prefix": "/build/" },
      "action": { "cache": true, "ttl": "30d" }
    },
    {
      "name": "laravel_storage",
      "match": { "path_prefix": "/storage/" },
      "action": { "cache": true, "ttl": "7d" }
    },
    {
      "name": "laravel_vendor",
      "match": { "path_prefix": "/vendor/" },
      "action": { "cache": true, "ttl": "30d" }
    },
    {
      "name": "laravel_livewire",
      "match": { "path_prefix": "/livewire/" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "laravel_sanctum",
      "match": { "path_prefix": "/sanctum/" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "laravel_api",
      "match": { "path_prefix": "/api/" },
      "action": { "cache": true, "ttl": "5m", "methods": ["GET"] }
    },
    {
      "name": "laravel_login",
      "match": { "path": "/login" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "laravel_register",
      "match": { "path": "/register" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "laravel_dashboard",
      "match": { "path_prefix": "/dashboard" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "laravel_admin",
      "match": { "path_prefix": "/admin" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "laravel_session",
      "match": { "cookie_regex": "laravel_session" },
      "action": { "cache": false, "pass": true }
    }
  ]
}

Symfony

Symfony is a PHP framework with native Edge Side Includes (ESI) support, making it a natural fit for Trident's ESI processing. This template enables Trident's ESI engine to assemble page fragments at the edge, caches Webpack Encore build assets and bundle assets with long TTLs, and bypasses the Symfony Profiler and Web Debug Toolbar routes that are active in development mode. API endpoints are cached (GET only), and admin and login routes pass through uncached.

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": {
    "symfony": {
      "host": "127.0.0.1",
      "port": 8000
    }
  },
  "directors": {
    "default": {
      "backends": ["symfony"],
      "strategy": "round_robin"
    }
  },
  "rules": [
    {
      "name": "symfony_assets",
      "match": { "path_prefix": "/build/" },
      "action": { "cache": true, "ttl": "30d" }
    },
    {
      "name": "symfony_bundles",
      "match": { "path_prefix": "/bundles/" },
      "action": { "cache": true, "ttl": "30d" }
    },
    {
      "name": "symfony_profiler",
      "match": { "path_prefix": "/_profiler" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "symfony_wdt",
      "match": { "path_prefix": "/_wdt" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "symfony_api",
      "match": { "path_prefix": "/api/" },
      "action": { "cache": true, "ttl": "5m", "methods": ["GET"] }
    },
    {
      "name": "symfony_admin",
      "match": { "path_prefix": "/admin" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "symfony_login",
      "match": { "path": "/login" },
      "action": { "cache": false, "pass": true }
    }
  ],
  "esi": {
    "enabled": true
  }
}

Django

Django is a Python framework with a built-in admin panel and session-based authentication. This template caches static files collected by collectstatic and media uploads with appropriate TTLs, bypasses the Django admin panel and Django Debug Toolbar routes, caches API endpoints (GET only), and skips the cache for authenticated users detected via the sessionid cookie. Account management routes under /accounts/ pass through uncached for login, logout, and registration flows.

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": {
    "django": {
      "host": "127.0.0.1",
      "port": 8000
    }
  },
  "directors": {
    "default": {
      "backends": ["django"],
      "strategy": "round_robin"
    }
  },
  "rules": [
    {
      "name": "django_static",
      "match": { "path_prefix": "/static/" },
      "action": { "cache": true, "ttl": "30d" }
    },
    {
      "name": "django_media",
      "match": { "path_prefix": "/media/" },
      "action": { "cache": true, "ttl": "7d" }
    },
    {
      "name": "django_admin",
      "match": { "path_prefix": "/admin/" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "django_api",
      "match": { "path_prefix": "/api/" },
      "action": { "cache": true, "ttl": "5m", "methods": ["GET"] }
    },
    {
      "name": "django_accounts",
      "match": { "path_prefix": "/accounts/" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "django_debug_toolbar",
      "match": { "path_prefix": "/__debug__/" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "django_session",
      "match": { "cookie_regex": "sessionid" },
      "action": { "cache": false, "pass": true }
    }
  ]
}

FastAPI

FastAPI is a Python async framework designed for high-performance API development. This template uses a 1 GB cache with a shorter 30-minute default TTL suited for API-heavy workloads, bypasses the Swagger UI (/docs) and ReDoc (/redoc) interactive documentation routes, caches the OpenAPI spec (/openapi.json) with a 1-hour TTL, and caches API endpoints (GET only) with a 5-minute TTL. Authentication routes, health check endpoints, and WebSocket paths 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": "1GB",
    "default_ttl": "30m",
    "stale_while_revalidate": "60s",
    "stale_if_error": "300s",
    "tags": {
      "enabled": true,
      "header_name": "X-Cache-Tags",
      "separator": ","
    }
  },
  "backends": {
    "fastapi": {
      "host": "127.0.0.1",
      "port": 8000
    }
  },
  "directors": {
    "default": {
      "backends": ["fastapi"],
      "strategy": "round_robin"
    }
  },
  "rules": [
    {
      "name": "fastapi_docs",
      "match": { "path": "/docs" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "fastapi_redoc",
      "match": { "path": "/redoc" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "fastapi_openapi",
      "match": { "path": "/openapi.json" },
      "action": { "cache": true, "ttl": "1h" }
    },
    {
      "name": "fastapi_static",
      "match": { "path_prefix": "/static/" },
      "action": { "cache": true, "ttl": "30d" }
    },
    {
      "name": "fastapi_api",
      "match": { "path_prefix": "/api/" },
      "action": { "cache": true, "ttl": "5m", "methods": ["GET"] }
    },
    {
      "name": "fastapi_auth",
      "match": { "path_prefix": "/auth/" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "fastapi_health",
      "match": { "path": "/health" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "fastapi_websocket",
      "match": { "path_prefix": "/ws/" },
      "action": { "cache": false, "pass": true }
    }
  ]
}

Ruby on Rails

Ruby on Rails is a full-stack Ruby framework with a rich asset pipeline. This template caches Sprockets asset pipeline and Webpacker packs with long TTLs, bypasses Devise authentication routes under /users/, keeps Action Cable WebSocket connections uncached for real-time features, and skips the Sidekiq dashboard. API endpoints are cached (GET only), and session-based authentication is detected via the _session cookie pattern to ensure logged-in users always hit 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": {
    "rails": {
      "host": "127.0.0.1",
      "port": 3000
    }
  },
  "directors": {
    "default": {
      "backends": ["rails"],
      "strategy": "round_robin"
    }
  },
  "rules": [
    {
      "name": "rails_assets",
      "match": { "path_prefix": "/assets/" },
      "action": { "cache": true, "ttl": "30d" }
    },
    {
      "name": "rails_packs",
      "match": { "path_prefix": "/packs/" },
      "action": { "cache": true, "ttl": "30d" }
    },
    {
      "name": "rails_admin",
      "match": { "path_prefix": "/admin" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "rails_api",
      "match": { "path_prefix": "/api/" },
      "action": { "cache": true, "ttl": "5m", "methods": ["GET"] }
    },
    {
      "name": "rails_devise",
      "match": { "path_prefix": "/users/" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "rails_cable",
      "match": { "path_prefix": "/cable" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "rails_sidekiq",
      "match": { "path_prefix": "/sidekiq" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "rails_session",
      "match": { "cookie_regex": "_session" },
      "action": { "cache": false, "pass": true }
    }
  ]
}

Spring Boot

Spring Boot is a Java framework with a comprehensive ecosystem. This template caches static resources and WebJars with long TTLs, bypasses the Spring Actuator health and metrics endpoints, keeps Swagger UI interactive documentation uncached while caching the OpenAPI v3 spec for 1 hour, and skips the cache for OAuth2 authentication flows and the H2 console used in development. Session-based authentication is detected via the JSESSIONID cookie to ensure authenticated 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": {
    "spring": {
      "host": "127.0.0.1",
      "port": 8080
    }
  },
  "directors": {
    "default": {
      "backends": ["spring"],
      "strategy": "round_robin"
    }
  },
  "rules": [
    {
      "name": "spring_static",
      "match": { "path_prefix": "/static/" },
      "action": { "cache": true, "ttl": "30d" }
    },
    {
      "name": "spring_webjars",
      "match": { "path_prefix": "/webjars/" },
      "action": { "cache": true, "ttl": "30d" }
    },
    {
      "name": "spring_actuator",
      "match": { "path_prefix": "/actuator/" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "spring_swagger",
      "match": { "path_prefix": "/swagger-ui" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "spring_api_docs",
      "match": { "path_prefix": "/v3/api-docs" },
      "action": { "cache": true, "ttl": "1h" }
    },
    {
      "name": "spring_api",
      "match": { "path_prefix": "/api/" },
      "action": { "cache": true, "ttl": "5m", "methods": ["GET"] }
    },
    {
      "name": "spring_login",
      "match": { "path": "/login" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "spring_oauth",
      "match": { "path_prefix": "/oauth2/" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "spring_h2_console",
      "match": { "path_prefix": "/h2-console" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "spring_session",
      "match": { "cookie_regex": "JSESSIONID" },
      "action": { "cache": false, "pass": true }
    }
  ]
}

Next.js

Next.js is a React framework with built-in support for Incremental Static Regeneration (ISR). This template caches _next/static build assets with a 30-day TTL (these are content-hashed and immutable), _next/image optimized images for 7 days, and _next/data pre-rendered page data for 15 minutes. The stale-while-revalidate window is extended to 120 seconds to complement ISR workflows. API routes bypass the cache by default, with an override for explicitly public API endpoints. Pages with the x-nextjs-cache header respect the origin TTL set by ISR, allowing Trident to honor Next.js revalidation intervals automatically.

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": "120s",
    "stale_if_error": "300s",
    "tags": {
      "enabled": true,
      "header_name": "X-Cache-Tags",
      "separator": ","
    }
  },
  "backends": {
    "nextjs": {
      "host": "127.0.0.1",
      "port": 3000
    }
  },
  "directors": {
    "default": {
      "backends": ["nextjs"],
      "strategy": "round_robin"
    }
  },
  "rules": [
    {
      "name": "nextjs_static",
      "match": { "path_prefix": "/_next/static/" },
      "action": { "cache": true, "ttl": "30d" }
    },
    {
      "name": "nextjs_image",
      "match": { "path_prefix": "/_next/image" },
      "action": { "cache": true, "ttl": "7d" }
    },
    {
      "name": "nextjs_data",
      "match": { "path_prefix": "/_next/data/" },
      "action": { "cache": true, "ttl": "15m" }
    },
    {
      "name": "nextjs_api",
      "match": { "path_prefix": "/api/" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "nextjs_api_public",
      "match": { "path_prefix": "/api/public/" },
      "action": { "cache": true, "ttl": "5m", "methods": ["GET"] }
    },
    {
      "name": "nextjs_auth",
      "match": { "path_prefix": "/auth/" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "nextjs_dashboard",
      "match": { "path_prefix": "/dashboard" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "nextjs_isr",
      "match": { "header": { "name": "x-nextjs-cache", "value_regex": ".*" } },
      "action": { "cache": true, "respect_origin_ttl": true }
    }
  ]
}

Nuxt.js

Nuxt.js is a Vue.js framework with server-side rendering and static site generation. This template caches _nuxt build assets (JavaScript, CSS, and other bundled files) with a 30-day TTL since they are content-hashed, and payload data for 15 minutes to keep pre-fetched page data fresh. The stale-while-revalidate window is set to 120 seconds to support smooth page transitions. API endpoints are cached (GET only) with a 5-minute TTL, while authentication routes, admin panels, and dashboard pages bypass the cache. Session-based authentication is detected via the nuxt-session cookie.

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": "120s",
    "stale_if_error": "300s",
    "tags": {
      "enabled": true,
      "header_name": "X-Cache-Tags",
      "separator": ","
    }
  },
  "backends": {
    "nuxtjs": {
      "host": "127.0.0.1",
      "port": 3000
    }
  },
  "directors": {
    "default": {
      "backends": ["nuxtjs"],
      "strategy": "round_robin"
    }
  },
  "rules": [
    {
      "name": "nuxtjs_build",
      "match": { "path_prefix": "/_nuxt/" },
      "action": { "cache": true, "ttl": "30d" }
    },
    {
      "name": "nuxtjs_payload",
      "match": { "path_prefix": "/_payload/" },
      "action": { "cache": true, "ttl": "15m" }
    },
    {
      "name": "nuxtjs_api",
      "match": { "path_prefix": "/api/" },
      "action": { "cache": true, "ttl": "5m", "methods": ["GET"] }
    },
    {
      "name": "nuxtjs_auth",
      "match": { "path_prefix": "/auth/" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "nuxtjs_admin",
      "match": { "path_prefix": "/admin" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "nuxtjs_dashboard",
      "match": { "path_prefix": "/dashboard" },
      "action": { "cache": false, "pass": true }
    },
    {
      "name": "nuxtjs_auth_cookie",
      "match": { "cookie_regex": "nuxt-session" },
      "action": { "cache": false, "pass": true }
    }
  ]
}
Was this page helpful?
Web Framework Templates — Trident Templates — Trident HTTP Cache Proxy | qoliber Docs