Skip to main content

Django app for automatically identifying and reloading stale web pages

Project description

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 the head* 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

local_reload-1.2.2.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

local_reload-1.2.2-py3-none-any.whl (24.4 kB view details)

Uploaded Python 3

File details

Details for the file local_reload-1.2.2.tar.gz.

File metadata

  • Download URL: local_reload-1.2.2.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using 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.43.0 CPython/3.6.10

File hashes

Hashes for local_reload-1.2.2.tar.gz
Algorithm Hash digest
SHA256 ea5e1232282aa6179e3bf2d36f658ddae64ec9546909b336ecb608df40cb940f
MD5 d09af8b4ad1b7e3cb8e893e5b5b5d3b8
BLAKE2b-256 7311daf94285f0048933730efbe433541b620b0a269edbe8b5863bc94a01079c

See more details on using hashes here.

File details

Details for the file local_reload-1.2.2-py3-none-any.whl.

File metadata

  • Download URL: local_reload-1.2.2-py3-none-any.whl
  • Upload date:
  • Size: 24.4 kB
  • Tags: Python 3
  • Uploaded using 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.43.0 CPython/3.6.10

File hashes

Hashes for local_reload-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 87bf4508c845f650c6932a72acab29a301cde0431ba6bc285fed1f556b97d9d7
MD5 f70e5c1dd87c060d54617f658d11bee7
BLAKE2b-256 f795d0330ba07216a198bcb6dd3b7a52bb2e76c58c512d4cb1233b9bc7dbc952

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page