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

Back / Foward Browser buttons loading HTMX partial content only #1201

Closed
helixaros opened this issue Jan 14, 2023 · 6 comments
Closed

Back / Foward Browser buttons loading HTMX partial content only #1201

helixaros opened this issue Jan 14, 2023 · 6 comments

Comments

@helixaros
Copy link

Hi there,

I have a url "/settings/users/" where it loads the list of users along with some filtering /searching functionality.
When a user is added on the list / removed I have an HX-Trigger, and the list is rerendered (only the list not the whole page).

If I press the back / forward button (with the previous step being adding / removing a user from the list), then it loads only the partial (doesn't load the full page), and therefore the page breaks (as js / css is not loaded). Example attached. I have seen some discussions happening around this topic, but I am not sure of the resolution that I should take to fix this issue.

Thank you in advance.

Screenshot 2023-01-14 at 10 05 01 AM

@Frohus
Copy link

Frohus commented Jan 16, 2023

I'm experiencing the same issue.
I have an htmx search form with hx-push-url on the home page, when submitted htmx makes a swap in the div on the homepage, then when I click on one of the filtered entries it takes me to its page (no htmx) and when I press back button only the previously filtered entries partial template is loaded not the whole page with that partial as expected

@David-Guillot
Copy link
Contributor

Hi there,

Might be related to #724 , and #1206 might help.

@David-Guillot
Copy link
Contributor

Hi @helixaros @Frohus ,

Can you confirm this issue is gone with latest 1.8.5? 613f7b6 appears to fix it with a configurable (disabled by default) cache-busting query-param.

@Frohus
Copy link

Frohus commented Jan 18, 2023

@David-Guillot just checked, it's still present

@1cg
Copy link
Contributor

1cg commented Feb 2, 2023

You should be able to fix this with a cache busting option as of 1.8.5, but you will need to configure it.

See the documentation here for dealing with this issue:

https://htmx.org/docs/#caching

@gnat
Copy link
Contributor

gnat commented Feb 4, 2024

tl;dr:

<script>htmx.config.getCacheBusterParam = true</script>

Can just be in your <head> somewhere after you load htmx.

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

5 participants