Skip to content

Commit

Permalink
Serve data from shoebox if storefront.maxAge is not set (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-ppl-ai authored Feb 26, 2021
1 parent ad1a07c commit f4ec49c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
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

0 comments on commit f4ec49c

Please sign in to comment.