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

Disable htmx.config.historyEnabled does not disable history cache #3049

Open
xhaggi opened this issue Nov 29, 2024 · 4 comments
Open

Disable htmx.config.historyEnabled does not disable history cache #3049

xhaggi opened this issue Nov 29, 2024 · 4 comments

Comments

@xhaggi
Copy link
Contributor

xhaggi commented Nov 29, 2024

I assumed that disabling htmx.config.historyEnabled would disable all history processing. However, this does not disable the creation of the history cache and the restoring of pages from the cache. To achieve this, you need to explicitly set htmx.config.historyCacheSize = 0. In my opinion, this makes no sense, or have I missed something?

@Telroshan
Copy link
Collaborator

The doc states

defaults to true, really only useful for testing

which doesn't help much to understand the initial intent of this property, and issues #2587 and #2232 point out a similar issue (having to also set historyCacheSize)

Looked at git blames, looks like this property has been there for quite some time, added in 2020 in 00e2249
Turns out, even at that time, the cache would still be populated even if history was disabled.

I would personally say feel free to open a bugfix PR as it indeed doesn't sound very logical that disabling history doesn't really disable it
@1cg might be able to tell you whether this was intended or not when he wrote this, maybe there's a gotcha I'm unaware of

@MichaelWest22
Copy link
Contributor

It seems to me that this config value only currently disables the htmx code that calls the history api to push/replace state to up-date browsers history data. But it does not disable the htmx history feature feature code itself so with this set off you are left with a kind of half working htmx history feature. My best guess is that the ability to disable the history API was done for testing purposes as documentation shows as all the test suites have this config disabled even though they do in fact test and validate history functionality. So changing this config to be more logical and also force history cache size to 0 will likely mean trying to re-write all the history tests and possibly then finding the hard way why this config value was added originally.

@1cg
Copy link
Contributor

1cg commented Dec 2, 2024

yeah, this was only for testing and obviously isn't complete

maybe we should remove it from the docs entirely so people don't try to use it?

@xhaggi
Copy link
Contributor Author

xhaggi commented Dec 2, 2024

I don't like the idea of removing it from the docs instead of implementing it properly, because this setting is useful if you want to disable the whole history feature and therefore URLs of boosted elements won't be pushed to the history. It wouldn't be that hard to fix it.

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

4 participants