Skip to content

Conversation

@mitom
Copy link

@mitom mitom commented Dec 16, 2015

Added hooks (generators) to be able to reliably and nicely tell when prerendering is going to happen or already has happened since they are only yielded to if the respective situation happens.

The afterPrerender is pretty useless if we consider that whatever has yielded to koa-prerender will have control back and always have access to the X-Prerender header and the context as well. I only added it for the sake of consistency.

This makes it possible to cache the result and possibly save a decent amount of resources.

It will also no longer yield down the stack when prerendering happens. The reason for this is simple: it used to overwrite the body of the response anyway so letting it run down and up is just wasting resources. Any other things that are supposed to happen after it can now happen in the after hook, or in a middleware above it which will then have access to the X-Prerender header at all times.

This is technically a breaking change, but in truth it only affects those who relied on this yield down the stack for some reason. Nevertheless it bumps the major

Closes #11
Possibly solves #9

* added beforePrerender and afterPrerender as optionals
* it no longer yields down when it prerenders
* major bumped due to no longer yielding
@mitom mitom closed this Jan 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Caching

1 participant