Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added before and after hooks #12

Closed
wants to merge 1 commit into from
Closed

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