Gothic Framework G symbol

Regenerated Static Pages (ISR)

As mentioned in our previous session, creating Regenerated Static Pages (ISR) with the Gothic Framework is as simple as adding a route config. The only difference is that you'll also need to change the config Type to ISR and add RevalidateInSec. By default, the framework sets Cache-Control headers so that a CDN like AWS CloudFront caches your page across its edge locations for the TTL period you specify. You can also use other cache strategies such as In-Memory, Redis, or Local Files. See the example below for how to configure it:

If you add logic to the Middleware function, you can pass custom props to your pages. These props will be used to render the page, which—if it's an ISR page—will be cached for the duration set in RevalidateInSec 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: 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 an 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.ISR,
	HttpMethod: routes.GET,
	RevalidateInSec: 10,
	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!