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.
import routes "github.com/felipegenef/gothicframework/v2/pkg/helpers/routes"
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
},
}
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!