Gothic Framework G symbol

Static Pages

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.

Security Note: STATIC and ISR pages are public — their responses are cacheable at the CDN, browser, or server-side cache store. Never render user-specific or access-controlled content in them. The Middleware function is the props loader: on a STATIC or ISR route it runs on a cache miss and produces the props the page renders with. If the middleware answers with a redirect or error status (≥ 300), that response is final — the page does not render and nothing is cached.

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
		}, 
 }

Did you like this Next.js-like feature? Check out other components as well! Click the button below to explore more features!