local_reload
Provides a means of identifying and automatically reloading "stale" pages.
Keeps a "last update time" in localStorage, and updates it whenever the user "updates data". Any time the user "returns" to a page (via browser history, or switches tabs/windows), that page will automatically reload if it is stale (if it was rendered before the last update time).
Intended for use on CRUD heavy sites, especially when you use history.back() or use multiple tabs/windows as part of the normal workflow.
Limitations
Update Time is Per-Browser
If data is updated in one browser, it will not reload pages in another browser. This is designed for a single user updating and viewing data in a single browser. We use window.localStorage to store the update time, so our scope is the same as that of localStorage (hence the name "local_reload").
Update Time is Site-Wide
A single, site-wide "update time" is maintained. A change in one piece of data will invalidate all previously rendered pages, even if they do not display that data.
Update Detection
We automatically reset the update time when any form is POSTed. To be more precise - we reset the update time on every form submit event, as long as the form's method is not GET.
This works well if you use actual form submissions (even if handled via javascript) as the event which triggers data updates. If you update data without the user submitting a form, then you must manually call window.local_reload_invalidate().
No Background Reload
Pages will not be reloaded in background tabs/windows. They will only be reloaded when the user returns focus to them. This is actually by design. Previous attempts to reload background windows/tabs resulted in undesirable behaviour in many situations.
Installation
pip install local_reload- add 'local_reload' to
INSTALLED_APPS {% include "local_reload/local_reload_support.html" %}in thehead* of any page that displays or updates data
* This should be added near the top of your head, so it can run as early as possible.
window.disable_local_reload
Set this to true if you want to temporarily/conditionally disable local reload on the given window.
NavTricks
We include a copy of NavTricks.js in our static files. This script pairs perfectly with local_reload.
Metadata
Release files for local-reload 1.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| local_reload-1.2.4.tar.gz | 10.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| local_reload-1.2.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 36.9 kB
Release files / local_reload-1.2.4.tar.gz
| Download URL | local_reload-1.2.4.tar.gz |
|---|---|
| Size | 10.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e06a2e8f9278264a03bf373db94f3a616759002435a4f36886b8db0935665276
|
|
BLAKE2b-256 checksum How to use checksums |
6c5f3e71c36b047858010541ae0c9649155333ec0dd2046c0ca41ea5da4924db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.10
|
Release files / local_reload-1.2.4-py3-none-any.whl
| Download URL | local_reload-1.2.4-py3-none-any.whl |
|---|---|
| Size | 26.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
36eae84100846d0f5ef82ada6e9b49e0cb67601a14be847698335be19ca64aa9
|
|
BLAKE2b-256 checksum How to use checksums |
f81719d22820ffd93b58532e726171fdd7bf6475baddeb28acee6c6e065c1d04
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.10
|
Security for local-reload 1.2.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.