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

Duplicated requests when leaving page with hx-boost #2618

Open
GaelGirodon opened this issue Jun 15, 2024 · 0 comments
Open

Duplicated requests when leaving page with hx-boost #2618

GaelGirodon opened this issue Jun 15, 2024 · 0 comments

Comments

@GaelGirodon
Copy link

GaelGirodon commented Jun 15, 2024

Some requests issued when navigating to a page (e.g. getting an image) are issued again when leaving the page by clicking on a link to navigate to another page, using hx-boost.

Steps to reproduce

  • Get the files from this Gist
  • Start a local PHP development server: php -S localhost:8000
  • Open http://localhost:8000/page1.php
  • Open the network inspector
  • Navigate between page1.php and page2.php, multiple times, with JS/htmx enabled, then disabled

Actual

  • With JS/htmx: a request to stream.php is issued each time (when navigating to and from page1.php), even if only page1.php has the <img> tag ❌

with htmx

  • Without JS/htmx: the request to stream.php is only issued when navigating to page1.php ✔️

without htmx

Expected

The request to stream.php should only be issued when navigating to (and not from) page1.php, in both cases.

➡️ Using hx-boost shouldn't trigger additional requests. Does htmx DOM manipulation is responsible for triggering these requests? On pages with many resources (multiple <img> elements), this can lead to a lot of useless additional requests to be sent. Can we prevent this?

Some more things I've tested

  • Disabling the cache doesn't seem to solve the problem (historyCacheSize = 0, historyEnabled = false)
  • Using @hotwired/turbo (instead of htmx + hx-boost), with prefetch disabled (turbo-prefetch = false):
    • With cache enabled (default): the same issue happens
    • With cache disabled (turbo-cache-control = no-cache): the issue disappears

Environment

  • htmx: 1.9.12 (from CDN or from NPM + bundled using Vite)
  • Browser: Firefox 127, Chrome 125
  • Backend: Go/Echo, PHP
  • OS: Windows 11

PS: thanks for this great library!

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

No branches or pull requests

1 participant