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

First page load is not cached, but could be fetched automatically in background #602

Closed
Tracked by #703
xavierfoucrier opened this issue Jan 29, 2021 · 8 comments
Closed
Tracked by #703
Assignees
Labels
@barba/core @barba/core plugin bug bug to fix
Milestone

Comments

@xavierfoucrier
Copy link
Member

Barba caching is not working on first page load.

When loading the home, the page won't be cached.
Navigating to another page and go back will make the home page properly cached.

Related issue #383.

@xavierfoucrier xavierfoucrier added bug bug to fix @barba/core @barba/core plugin labels Jan 29, 2021
@geraldnako
Copy link
Contributor

geraldnako commented Jan 29, 2021

Adding barba.cache.set(next.url.href, next.html, 'init'); on the once hook will cache the first loaded page.

@xavierfoucrier
Copy link
Member Author

xavierfoucrier commented Jan 29, 2021

Thanks @geraldnako for the quick workaround! 😉

@stale stale bot added the wontfix negligible issue or that will never be fixed label Jun 9, 2021
@xavierfoucrier xavierfoucrier removed the wontfix negligible issue or that will never be fixed label Jun 9, 2021
@barbajs barbajs deleted a comment from stale bot Jan 31, 2022
@thierrymichel thierrymichel self-assigned this Jan 31, 2022
@thierrymichel thierrymichel changed the title First page load is not cached First page load is not cached, but could be fetched automatically in background Jan 31, 2022
@xavierfoucrier xavierfoucrier added this to the barba@next milestone Apr 26, 2023
xavierfoucrier added a commit that referenced this issue Apr 30, 2023
@xavierfoucrier xavierfoucrier mentioned this issue May 5, 2023
15 tasks
@daun
Copy link

daun commented Jun 9, 2023

Doesn't the (new) solution re-introduce the old issue #383 by caching the (possibly already modified) html of the current page? To make this fool-proof, one would have to fetch/preload the page in the background and cache the returned html.

@xavierfoucrier
Copy link
Member Author

Hi @daun 👋

Thanks for pointing this out.

From what I have tested, the first page was not cached at all: Barba was making a new request when using backward navigation to the home. In order to give an appropriate answer to this, I have added it again to my notes, so I can do additional tests and give a feedback on that 😉.

@daun
Copy link

daun commented Jun 9, 2023

Sounds good! Maybe this could be a setting? That way, consumers can explicitly turn it off if they run into problems with caching the already modified html.

@xavierfoucrier
Copy link
Member Author

Hi @daun 👋

Sorry for the late feedback 🌊
You are right: adding a setting is clearly the solution to make everyone happy 😉

I will open an additional issue to make things clear.
From my point of view, that setting have to be true by default, what do you think? 🤔

@daun
Copy link

daun commented Jul 27, 2023

@xavierfoucrier Wonderful! I think having it true or false is fine either way. But I guess you could choose the solution that doesn't involve a breaking change :)

@xavierfoucrier
Copy link
Member Author

@daun sure 👌 , thanks for your feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@barba/core @barba/core plugin bug bug to fix
Projects
None yet
Development

No branches or pull requests

4 participants