Skip to content

Web Framework Templates

These complete configurations require a valid Trident Core licence at /etc/trident/license.key, readable by the service user. The explicit license.path below selects that file; mounting a licence without configuring its path does not activate caching. A successful --check validates the configuration, not the entitlement. Verify licensed runtime status and a cacheable MISS followed by HIT with identical complete bodies.

Configuration validation is not an integration test

These JSON examples are checked with the Trident 1.8.0 parser. That confirms configuration acceptance, not live application behavior, production readiness, or coverage of every platform version. Keep the origin's private, no-store, authorization and session protections; validate exact anonymous/customer/cart bodies and invalidation in your own deployment. Request-phase pass rules take precedence over response TTL rules.

Replace example.com and www.example.com in cache.poisoning.known_hosts with every hostname this instance actually serves, and set TRIDENT_ADMIN_TOKEN to a strong secret in the service environment. The admin and metrics endpoints below bind to loopback. Per-rule TTLs remain capped by ttl.max; origin freshness takes precedence where no rule overrides it.

Backend addresses must point to an HTTP application/web server, not directly to a PHP-FPM/FastCGI listener. Replace example ports with the actual HTTP endpoint.

Save JSON as /etc/trident/config.json (not a .toml file), select that path with TRIDENT_CONFIG=/etc/trident/config.json in /etc/default/trident, and run trident --config /etc/trident/config.json --check before the normal reload/restart procedure. A TOML deployment must use a real TOML translation and its corresponding selected path.

Configuration starting points for the current Trident Core schema. Application behavior and installed package versions require separate qualification.


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.

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.

{
  "license": {
    "path": "/etc/trident/license.key"
  },
  "server": {
    "listeners": [
      {
        "address": "0.0.0.0:8080",
        "protocol": "http1"
      }
    ]
  },
  "cache": {
    "tags": {
      "separator": ",",
      "headers": [
        "X-Cache-Tags"
      ]
    },
    "max_memory": "2GB",
    "grace_period": "60s",
    "stale_while_revalidate": {
      "enabled": true
    },
    "stale_if_error": {
      "enabled": true,
      "max_stale_age": "300s"
    },
    "poisoning": {
      "known_hosts": [
        "example.com",
        "www.example.com"
      ]
    }
  },
  "backends": [
    {
      "name": "symfony",
      "host": "127.0.0.1",
      "port": 8000
    }
  ],
  "directors": [
    {
      "name": "default",
      "backends": [
        "symfony"
      ],
      "strategy": "round_robin"
    }
  ],
  "rules": {
    "request": [
      {
        "name": "symfony_profiler",
        "match": {
          "path": {
            "pattern": "^/_profiler"
          }
        },
        "priority": 102,
        "action": "pass"
      },
      {
        "name": "symfony_wdt",
        "match": {
          "path": {
            "pattern": "^/_wdt"
          }
        },
        "priority": 103,
        "action": "pass"
      },
      {
        "name": "symfony_admin",
        "match": {
          "path": {
            "pattern": "^/admin"
          }
        },
        "priority": 105,
        "action": "pass"
      },
      {
        "name": "symfony_login",
        "match": {
          "path": "/login"
        },
        "priority": 106,
        "action": "pass"
      }
    ],
    "response": [
      {
        "name": "symfony_assets",
        "match": {
          "path": {
            "pattern": "^/build/"
          }
        },
        "priority": 100,
        "action": {
          "ttl": "30d"
        }
      },
      {
        "name": "symfony_bundles",
        "match": {
          "path": {
            "pattern": "^/bundles/"
          }
        },
        "priority": 101,
        "action": {
          "ttl": "30d"
        }
      },
      {
        "name": "symfony_api",
        "match": {
          "path": {
            "pattern": "^/api/"
          },
          "method": [
            "GET"
          ]
        },
        "priority": 104,
        "action": {
          "ttl": "5m"
        }
      }
    ]
  },
  "esi": {
    "enabled": true
  },
  "admin": {
    "enabled": true,
    "address": "127.0.0.1:9100",
    "auth_token": "${TRIDENT_ADMIN_TOKEN}"
  },
  "metrics": {
    "enabled": true,
    "address": "127.0.0.1:9191",
    "path": "/metrics",
    "stats_path": "/stats"
  },
  "ttl": {
    "mode": "origin",
    "default": "1h",
    "max": "30d"
  }
}

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.

FastAPI

Qualification: configuration example only; no live integration coverage is established here.

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.

{
  "license": {
    "path": "/etc/trident/license.key"
  },
  "server": {
    "listeners": [
      {
        "address": "0.0.0.0:8080",
        "protocol": "http1"
      }
    ]
  },
  "cache": {
    "tags": {
      "separator": ",",
      "headers": [
        "X-Cache-Tags"
      ]
    },
    "max_memory": "1GB",
    "grace_period": "60s",
    "stale_while_revalidate": {
      "enabled": true
    },
    "stale_if_error": {
      "enabled": true,
      "max_stale_age": "300s"
    },
    "poisoning": {
      "known_hosts": [
        "example.com",
        "www.example.com"
      ]
    }
  },
  "backends": [
    {
      "name": "fastapi",
      "host": "127.0.0.1",
      "port": 8000
    }
  ],
  "directors": [
    {
      "name": "default",
      "backends": [
        "fastapi"
      ],
      "strategy": "round_robin"
    }
  ],
  "rules": {
    "request": [
      {
        "name": "fastapi_docs",
        "match": {
          "path": "/docs"
        },
        "priority": 100,
        "action": "pass"
      },
      {
        "name": "fastapi_redoc",
        "match": {
          "path": "/redoc"
        },
        "priority": 101,
        "action": "pass"
      },
      {
        "name": "fastapi_auth",
        "match": {
          "path": {
            "pattern": "^/auth/"
          }
        },
        "priority": 105,
        "action": "pass"
      },
      {
        "name": "fastapi_health",
        "match": {
          "path": "/health"
        },
        "priority": 106,
        "action": "pass"
      },
      {
        "name": "fastapi_websocket",
        "match": {
          "path": {
            "pattern": "^/ws/"
          }
        },
        "priority": 107,
        "action": "pass"
      }
    ],
    "response": [
      {
        "name": "fastapi_openapi",
        "match": {
          "path": "/openapi.json"
        },
        "priority": 102,
        "action": {
          "ttl": "1h"
        }
      },
      {
        "name": "fastapi_static",
        "match": {
          "path": {
            "pattern": "^/static/"
          }
        },
        "priority": 103,
        "action": {
          "ttl": "30d"
        }
      },
      {
        "name": "fastapi_api",
        "match": {
          "path": {
            "pattern": "^/api/"
          },
          "method": [
            "GET"
          ]
        },
        "priority": 104,
        "action": {
          "ttl": "5m"
        }
      }
    ]
  },
  "admin": {
    "enabled": true,
    "address": "127.0.0.1:9100",
    "auth_token": "${TRIDENT_ADMIN_TOKEN}"
  },
  "metrics": {
    "enabled": true,
    "address": "127.0.0.1:9191",
    "path": "/metrics",
    "stats_path": "/stats"
  },
  "ttl": {
    "mode": "origin",
    "default": "30m",
    "max": "30d"
  }
}

Ruby on Rails

Status: beta / configuration example only. Rails is not promoted to a qualified integration by this parser check.

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.

Spring Boot

Qualification: configuration example only; no live integration coverage is established here.

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.

Next.js

Qualification: configuration example only; no live integration coverage is established here.

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, including the /api/public/ path while the broader request-phase bypass remains. A response TTL rule alone cannot override that bypass. The global ttl.mode = "origin" respects ordinary origin freshness unless a response TTL rule overrides it. The nextjs_isr rule adds no TTL override; no special ISR synchronization is established by this configuration.

{
  "license": {
    "path": "/etc/trident/license.key"
  },
  "server": {
    "listeners": [
      {
        "address": "0.0.0.0:8080",
        "protocol": "http1"
      }
    ]
  },
  "cache": {
    "tags": {
      "separator": ",",
      "headers": [
        "X-Cache-Tags"
      ]
    },
    "max_memory": "2GB",
    "grace_period": "120s",
    "stale_while_revalidate": {
      "enabled": true
    },
    "stale_if_error": {
      "enabled": true,
      "max_stale_age": "300s"
    },
    "poisoning": {
      "known_hosts": [
        "example.com",
        "www.example.com"
      ]
    }
  },
  "backends": [
    {
      "name": "nextjs",
      "host": "127.0.0.1",
      "port": 3000
    }
  ],
  "directors": [
    {
      "name": "default",
      "backends": [
        "nextjs"
      ],
      "strategy": "round_robin"
    }
  ],
  "rules": {
    "request": [
      {
        "name": "nextjs_api",
        "match": {
          "path": {
            "pattern": "^/api/"
          }
        },
        "priority": 103,
        "action": "pass"
      },
      {
        "name": "nextjs_auth",
        "match": {
          "path": {
            "pattern": "^/auth/"
          }
        },
        "priority": 105,
        "action": "pass"
      },
      {
        "name": "nextjs_dashboard",
        "match": {
          "path": {
            "pattern": "^/dashboard"
          }
        },
        "priority": 106,
        "action": "pass"
      }
    ],
    "response": [
      {
        "name": "nextjs_static",
        "match": {
          "path": {
            "pattern": "^/_next/static/"
          }
        },
        "priority": 100,
        "action": {
          "ttl": "30d"
        }
      },
      {
        "name": "nextjs_image",
        "match": {
          "path": {
            "pattern": "^/_next/image"
          }
        },
        "priority": 101,
        "action": {
          "ttl": "7d"
        }
      },
      {
        "name": "nextjs_data",
        "match": {
          "path": {
            "pattern": "^/_next/data/"
          }
        },
        "priority": 102,
        "action": {
          "ttl": "15m"
        }
      },
      {
        "name": "nextjs_api_public",
        "match": {
          "path": {
            "pattern": "^/api/public/"
          },
          "method": [
            "GET"
          ]
        },
        "priority": 104,
        "action": {
          "ttl": "5m"
        }
      },
      {
        "name": "nextjs_isr",
        "match": {
          "header": {
            "x-nextjs-cache": {
              "pattern": ".*"
            }
          }
        },
        "priority": 107,
        "action": {}
      }
    ]
  },
  "admin": {
    "enabled": true,
    "address": "127.0.0.1:9100",
    "auth_token": "${TRIDENT_ADMIN_TOKEN}"
  },
  "metrics": {
    "enabled": true,
    "address": "127.0.0.1:9191",
    "path": "/metrics",
    "stats_path": "/stats"
  },
  "ttl": {
    "mode": "origin",
    "default": "1h",
    "max": "30d"
  }
}

Nuxt.js

Qualification: configuration example only; no live integration coverage is established here.

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.

{
  "license": {
    "path": "/etc/trident/license.key"
  },
  "server": {
    "listeners": [
      {
        "address": "0.0.0.0:8080",
        "protocol": "http1"
      }
    ]
  },
  "cache": {
    "tags": {
      "separator": ",",
      "headers": [
        "X-Cache-Tags"
      ]
    },
    "max_memory": "2GB",
    "grace_period": "120s",
    "stale_while_revalidate": {
      "enabled": true
    },
    "stale_if_error": {
      "enabled": true,
      "max_stale_age": "300s"
    },
    "poisoning": {
      "known_hosts": [
        "example.com",
        "www.example.com"
      ]
    }
  },
  "backends": [
    {
      "name": "nuxtjs",
      "host": "127.0.0.1",
      "port": 3000
    }
  ],
  "directors": [
    {
      "name": "default",
      "backends": [
        "nuxtjs"
      ],
      "strategy": "round_robin"
    }
  ],
  "rules": {
    "request": [
      {
        "name": "nuxtjs_auth",
        "match": {
          "path": {
            "pattern": "^/auth/"
          }
        },
        "priority": 103,
        "action": "pass"
      },
      {
        "name": "nuxtjs_admin",
        "match": {
          "path": {
            "pattern": "^/admin"
          }
        },
        "priority": 104,
        "action": "pass"
      },
      {
        "name": "nuxtjs_dashboard",
        "match": {
          "path": {
            "pattern": "^/dashboard"
          }
        },
        "priority": 105,
        "action": "pass"
      },
      {
        "name": "nuxtjs_auth_cookie",
        "match": {
          "header": {
            "Cookie": {
              "pattern": "nuxt-session"
            }
          }
        },
        "priority": 106,
        "action": "pass"
      }
    ],
    "response": [
      {
        "name": "nuxtjs_build",
        "match": {
          "path": {
            "pattern": "^/_nuxt/"
          }
        },
        "priority": 100,
        "action": {
          "ttl": "30d"
        }
      },
      {
        "name": "nuxtjs_payload",
        "match": {
          "path": {
            "pattern": "^/_payload/"
          }
        },
        "priority": 101,
        "action": {
          "ttl": "15m"
        }
      },
      {
        "name": "nuxtjs_api",
        "match": {
          "path": {
            "pattern": "^/api/"
          },
          "method": [
            "GET"
          ]
        },
        "priority": 102,
        "action": {
          "ttl": "5m"
        }
      }
    ]
  },
  "admin": {
    "enabled": true,
    "address": "127.0.0.1:9100",
    "auth_token": "${TRIDENT_ADMIN_TOKEN}"
  },
  "metrics": {
    "enabled": true,
    "address": "127.0.0.1:9191",
    "path": "/metrics",
    "stats_path": "/stats"
  },
  "ttl": {
    "mode": "origin",
    "default": "1h",
    "max": "30d"
  }
}