The WP SSR Framework ships a Static Site Generator (SSG) subsystem that pre-renders your React/Vite SPA pages into plain HTML files. Three REST endpoints underDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Ahondev/portfolio-v2/llms.txt
Use this file to discover all available pages before exploring further.
/api/v1/ssg/ drive this process: one to generate (or regenerate) a single page, one to cache every eligible post at once, and one to invalidate a cached file. All three endpoints are authenticated — they require a valid WordPress nonce in the request header and are intended to be called from the WP Admin SSG dashboard rather than from public-facing client code.
Authentication
Every/api/v1/ssg/* request must include an X-WP-Nonce header containing a nonce generated server-side with wp_create_nonce('wp_rest'). The WordPress REST API verifies this nonce automatically before the controller action runs.
How rendering works
When an SSG endpoint triggers HTML generation,StaticSiteGeneratorService calls an external headless-browser rendering API:
- Production:
https://api.ahon.dev/web/render - Development (
WP_ENV=development):http://127.0.0.1:8888/web/render
Bearer token from the WEB_RENDER_TOKEN environment variable. The service requests a full-page screenshot at a 1 440 × 900 viewport, waits for networkidle, and expects the API to return { success: true, html: "<string>" }.
The resulting HTML is written to web/app/cache/client/static/{slug}.html and three post-meta keys are updated on the WordPress post.
If
WEB_RENDER_TOKEN is not set the generator throws a RuntimeException immediately and the endpoint returns a 500 error response.POST /api/v1/ssg/page
Generates (or regenerates) the static HTML cache for a single WordPress post or page. This is the primary endpoint used by the admin dashboard’s per-item “Generate” button and its bulk-generation progress loop.
Base URL (with rewrites): POST /api/v1/ssg/pageBase URL (without rewrites):
POST /wp-json/api/v1/ssg/page
Request body
The WordPress post ID to render. Must pass PHP’s
FILTER_VALIDATE_INT. Accepted as a JSON body parameter or a query string value.Responses
true when HTML was generated and stored successfully.HTTP status code echoed in the body.
200 on success.Example request
Side effects
After a successful render,StaticSiteGeneratorService::storeHTML() performs three operations:
| Action | Detail |
|---|---|
| Writes HTML file | web/app/cache/client/static/{slug}.html — directory is created (0755) if it does not exist |
_ssg_cached_path | Post meta updated to the relative path /cache/client/static/{slug}.html |
_ssg_last_cached | Post meta updated to the current MySQL datetime via current_time('mysql') |
_ssg_content_hash | Post meta updated to md5(post_content . post_modified) for staleness detection |
slug is derived from post_name, falling back to post-{ID} when post_name is empty. The filename is run through sanitize_file_name() before writing.
POST /api/v1/ssg/all
Generates and caches static HTML for all cacheable posts and pages in a single request. The controller calls StaticSiteGeneratorService::getCacheableItems() to fetch the full list of cacheable posts, then calls generateHTML() on each item sequentially.
Base URL (with rewrites): POST /api/v1/ssg/allBase URL (without rewrites):
POST /wp-json/api/v1/ssg/all
Request body
No request body is required. The endpoint determines the cacheable set automatically.Responses
true when the operation completes.200 on success.Example request
DELETE /api/v1/ssg/delete
Deletes the cached static HTML file for a single WordPress post and clears all related post meta. Use this endpoint to invalidate a stale cache entry after content is updated, or to force a clean regeneration.
Base URL (with rewrites): DELETE /api/v1/ssg/deleteBase URL (without rewrites):
DELETE /wp-json/api/v1/ssg/delete
Request body
The WordPress post ID whose cache should be deleted. Must pass
FILTER_VALIDATE_INT.Responses
true when the deletion operation completes (even if no file existed on disk).200 on success./page)
Example request
Side effects
StaticSiteGeneratorService::deleteCachedFile() performs the following steps:
- Reads
_ssg_cached_pathpost meta. Returnsfalseimmediately if no path is stored. - Resolves the absolute path via
app_root($relativePath). - Calls
unlink()if the file exists and is a regular file. - Removes the three post-meta keys:
_ssg_cached_path,_ssg_last_cached,_ssg_content_hash.
If the
.html file has already been deleted from disk (e.g. manually or by a deployment script) the endpoint still returns deleted: true as long as the post meta entry existed — the meta cleanup happens regardless of whether the physical file was found.Route registration summary
The three SSG routes are registered insrc/_configuration/routes/api.php as a grouped route set:
/api/v1/ssg/page, /api/v1/ssg/all, and /api/v1/ssg/delete when URL rewrites are active, or /wp-json/api/v1/ssg/* as the fallback.