bigskysoftware / bigskysoftware/htmx

Possibly buggy cache handling when using hx-select / hx-target in htmx 2.x

Open
#2,865 9 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
49.4k
Forks
1.7k
Avg merge
3d 22h
Merged PRs (30d)
30

Description

I have two files "first.html"

```

First


First


```

and "second.html"

```

Second


Second


```

served by some (any) webserver from the same directory.

I open ```http://.../first.html``` in some browser (I tried Firefox, Chromium and MS Edge (Linux)) and perform the following steps:

| Action | URL in browser after action | content shown after action |
| ----------------------------- | ------------------------------------- | ------------------------------------ |
| | first.html | "First" |
| Click on link "Second" | second.html | "Second" |
| Browser "back" | first.html | "First" |
| Click on link "Second" | second.html | "Second" |
| Browser "back" | first.html | **"Second"** <-- _WTF?_ |

After the second time I stepped back through the browser history, URL and content have diverged!

Now if I **remove** ```hx-select="main" hx-target="main" hx-swap="outerHTML"``` and start again (SHIFT+F5 hard reload for "first.html") everything works.

Also, if I **keep** ```hx-select="main" hx-target="main" hx-swap="outerHTML"``` but **switch to HTMX 1.9.12** everything works, too.

So to me this really looks like a bug in HTMX 2.x?!

Can anyone confirm if it is a bug or show me what I'm doing wrong?

Thanks!
Heiko

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.