Cache index

This commit is contained in:
George Lacey 2021-05-18 16:25:58 +01:00
parent 549a483e74
commit 7736025e99
3 changed files with 17 additions and 2 deletions

View File

@ -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()

View File

@ -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',
}
}

View File

@ -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"