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

Add support for bfcache #4587

Closed
kevinoid opened this issue Jan 29, 2014 · 5 comments
Closed

Add support for bfcache #4587

kevinoid opened this issue Jan 29, 2014 · 5 comments
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. wontfix If you can reproduce this issue, please reopen the issue or create a new one describing it.
Milestone

Comments

@kevinoid
Copy link

Currently piwik.js unconditionally adds a listener to the beforeunload event. Unfortunately, this prevents "Back-Forward Cache"/"Page Cache"/"Fast History Navigation" on Firefox/Safari/Opera respectively.

Since the beforeunload event is only used to trigger unload plugins, would it be acceptable to defer registering the beforeunload event listener until addPlugin is called with an unload plugin? That way plugins will still get the event, but Piwik won't disable the bfcache unless a plugin requires it.

@robocoder
Copy link
Contributor

Even if we completely removed the plugin support, we would still require the event listener. The wait loop in the before unload handler is an important piece of functionality, i.e., required for outlink tracking (where supported by the browser).

So, yes, it prevents bfcaching, but this is as designed/intended. The immediate workaround is to use Piwik's server-side logging capability. Removing/disabling the before unload event listener is a compat buster, so won't happen in the 2.0.x branch.

@robocoder
Copy link
Contributor

@mattab
Copy link
Member

mattab commented Feb 1, 2014

Can this be fixed, if so do you know how?

@robocoder
Copy link
Contributor

This requires further investigation to see how well supported it is across browsers.

Latest Firefox and Safari fire pageshow event before onload, and pagehide before unload.

It might be something like:

Add event listener for 'pagehide'

Pagehide handler:
- remove unload handler (if still registered)
- call the unload handler directly

(Similarly for pageshow.)

Theoretically, this would allow the page to be cacheable by bfcache. Downsides: may introduce a delay for Back/Forward navigation. (Could mitigate this by keeping track of outstanding requests.)

@mattab
Copy link
Member

mattab commented Apr 6, 2014

Thanks Anthon. It sounds a bit complex so won't fix for now. Thanks for the discussion! If you have a patch please reopen

@kevinoid kevinoid added this to the 2.x - The Great Piwik 2.x Backlog milestone Jul 8, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. wontfix If you can reproduce this issue, please reopen the issue or create a new one describing it.
Projects
None yet
Development

No branches or pull requests

3 participants