Static pages are created in the src/pages folder by the Gothic Framework by default, if you do export a page route config. By default, the framework uses Cache-Control headers so that a CDN like AWS CloudFront can cache your page across all its edge locations for a TTL period of 1 year! You can also use other cache strategies such as In-Memory, Redis, or Local Files for self-hosted deployments. See the example below for how to configure a static page:
If you add logic to the Middleware function, you can pass custom props to your pages. These props will be used to render your page, which—if it's a static page—will be cached for one year (or until evicted, depending on the cache strategy you choose) before the Middleware is called again.
Important note 1: A route config is not required for components and pages, but all page and component functions MUST receive props, even if they are of type any and receive nil as value.
Important note 2: Your page or component must be the first function in your .templ file. If you need to add extra Go functions, please define them below your page or component function.
import routes "github.com/felipegenef/gothicframework/v2/pkg/helpers/routes"
type Props = interface { }
var PageConfig = routes.RouteConfig[ Props ]{
Type: routes.STATIC,
HttpMethod: routes.GET,
Middleware: func (w http.ResponseWriter , r *http.Request ) Props {
return nil
},
}
templ Page ( props Props ) { ... Did you like this Next.js-like feature? Check out other components as well! Click the button below to explore more features!