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

Serve data from shoebox if storefront.maxAge is not set #427

Merged
merged 1 commit into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions addon/mixins/fastboot-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ export default Mixin.create({
const maxAgeMinutes = config.storefront ? config.storefront.maxAge : undefined;

if (!isFastboot && box && box.queries && Object.keys(box.queries).length > 0) {
const valid = this.isDateValid(box.created, maxAgeMinutes);
const shouldUseShoebox = maxAgeMinutes === undefined || this.isDateValid(box.created, maxAgeMinutes);
let key = shoeboxize(cacheKey([type, url.replace(/^.*\/\/[^\/]+/, ''), params]));

if (valid) {
if (shouldUseShoebox) {
payload = box.queries[key];
}
delete box.queries[key];
Expand Down
2 changes: 2 additions & 0 deletions tests/dummy/app/pods/docs/guides/fastboot/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ Fastboot rendered pages need to be generated quickly, since they are rendered on

In certain cases, like the browser restoring its session, a cached version of the index.html page may be served, which contains shoebox data from the initial, cached request. The adapter is not aware that this data is stale, and outdated information is displayed to the user. To prevent this you can configure a duration after which data will no longer be served from the shoebox.

If the `maxAge` is not set, by default data will always be served from the shoebox.

```
// config/environment.js
ENV = {
Expand Down