Skip to content

Implement Caching Mechanism #2647

@tyler-8

Description

@tyler-8

Environment

  • Python version: 3.6.7
  • NetBox version: 2.4.8

Proposed Functionality

Django offers a caching mechanism to improve page load performance. The three primary methods are

  • per-site cache
  • per-view cache
  • template fragments

Per-site is invalidated strictly by the cache expiry time - meaning if you update an object, the changes don't appear until the cache for that view/page/object expires. This isn't very useful for Netbox workflows.

Per-view and template fragments could both benefit Netbox but would require changes across the project, mostly in the Django views in each area of Netbox. This would involve some sort of CacheMixin. Django's caching interface supports several methods for cache storage (filesystem, database, memcached, redis w/plugins).

The plugin django-cacheops sets up the cache using redis and automatically hooks in to Django's signal framework for invalidating caches as objects are created/updated/deleted. This option requires very little code changes other than adding new configurations.

Use Case

Ideally a user would only need to make a few changes to the configuration in order to select the caching storage method (in the case of the per-view method) and location. From there Netbox would cache on the fly without further intervention.

Database Changes

The database or Netbox model schema would not require any changes.

External Dependencies

Depends on the path chosen

Potentially:

  • redis
  • memcached
  • django-cacheops
  • Another SQL database/table (for cache storage)

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: acceptedThis issue has been accepted for implementation

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions