-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
hx-boost breaks site when re-opning closed tab (command-shift-T) #724
Comments
I can confirm this issue. I don't think it is intended. Problem is described at stackoverflow: After restoring tab browser shows last cached ajax response. You can use Cache-Control headers at server side to disable caching for Hx-Boosted requests. I belive it can be solved at the htmx side by adding timestamp to ajax requests to avoid caching. <div hx-boost="true" hx-target="#main-content">
<a href="/sample" >
<span>Sample page</span>
</a>
</div> If htmx could make request to |
After some rethink I thought about the downsides. |
You can use the Vary-Header to distinguish HTMX requests from regular ones:
|
Oh that's clever, I'll try it as soon as I can! |
@oliverhanappi @David-Guillot probably it won’t work. After reopening closed tab it will be returned from browser cache without hitting sever. |
There are two solutions.
|
in django adding no-cache headers when returning a fragment worked for me
|
@1cg what's your opinion on this? If you think solution 2 is the way to go, I'll open a PR here. Otherwise I'll open a PR on |
The https://htmx.org/docs/#caching But I am open to a change for boosted links where we submit a cache-busting parameter that isn't included in the URL pushed into the browser history as a pragmatic solution as well. That would certainly make things easier on htmx developers. @David-Guillot any interest in looking into this? A quick look at the code indicates it won't be trivial, but not impossible either... |
@1cg I'll give it a try. Have you seen Adam's arguments for not implementing systematic |
Okay everyone (especially @thekashifmalik and @kucharzyk), this issue can be closed, as 613f7b6 (released with 1.8.5) implements a configurable (disabled by default) cache-busting queryparam. |
Navigating back from an external link shows the response from the last AJAX request, a partial page. We'll tell the browser not to cache HTML responses. See also bigskysoftware/htmx#724
When reopening a closed tab (
command-shift-t
on Chrome) withhx-target
set to an element different than thebody
, the page loads only the partial content returned from the server. Is this intended behavior?The text was updated successfully, but these errors were encountered: