From 7736025e991289c48e2a86cc9c5a3e5a94fa46ed Mon Sep 17 00:00:00 2001 From: George Lacey Date: Tue, 18 May 2021 16:25:58 +0100 Subject: [PATCH] Cache index --- borgweb/borg/views.py | 2 ++ borgweb/borgweb/settings.py | 15 ++++++++++++++- borgweb/setup.sh | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/borgweb/borg/views.py b/borgweb/borg/views.py index 8eb6067..f2bac2f 100644 --- a/borgweb/borg/views.py +++ b/borgweb/borg/views.py @@ -7,8 +7,10 @@ from .forms import RepoForm, ArchiveForm, ErrorForm, LocationForm from django.contrib.auth.decorators import permission_required from .utility import data from datetime import datetime, timedelta +from django.views.decorators.cache import cache_page +@cache_page(60) def index(request): repo_list = Repo.objects.all() location_list = Location.objects.all() diff --git a/borgweb/borgweb/settings.py b/borgweb/borgweb/settings.py index cfc661d..5c3a8f7 100644 --- a/borgweb/borgweb/settings.py +++ b/borgweb/borgweb/settings.py @@ -20,7 +20,7 @@ SECRET_KEY = __SECRET_KEY DEBUG = True -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = ['127.0.0.1'] AXES_LOCKOUT_CALLABLE = "borg.views.axes" @@ -119,6 +119,11 @@ STATICFILES_FINDERS = [ ] COMPRESS_PRECOMPILERS = (('text/x-scss', 'django_libsass.SassCompiler'),) +COMPRESS_ENABLED = True +COMPRESS_OFFLINE = True +LIBSASS_OUTPUT_STYLE = 'compressed' +STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage' + STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'root') STATICFILES_DIRS = [ @@ -126,3 +131,11 @@ STATICFILES_DIRS = [ ] DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' + +# Cache +CACHES = { + 'default': { + 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', + 'LOCATION': 'unique-snowflake', + } +} diff --git a/borgweb/setup.sh b/borgweb/setup.sh index 0372722..1135a92 100644 --- a/borgweb/setup.sh +++ b/borgweb/setup.sh @@ -35,7 +35,7 @@ print_action "Installing pip packages, this may take a while..." # install required pip packages yes | python -m pip install --upgrade wheel -yes | python -m pip install django gunicorn sass django-libsass django-compressor django-axes +yes | python -m pip install django gunicorn django-libsass django-compressor django-axes pymemcache print_action "Setting up static files and database"