Optimise performance with caching
This commit is contained in:
parent
1f43a00c7a
commit
57078c10c1
|
@ -54,6 +54,24 @@ INSTALLED_APPS = [
|
|||
# "otp_yubikey",
|
||||
"mixins",
|
||||
]
|
||||
|
||||
|
||||
# Performance optimisations
|
||||
CACHES = {
|
||||
"default": {
|
||||
"BACKEND": "django.core.cache.backends.redis.RedisCache",
|
||||
"LOCATION": "unix:///var/run/socks/redis.sock",
|
||||
"OPTIONS": {
|
||||
"db": "10",
|
||||
"parser_class": "redis.connection.PythonParser",
|
||||
"pool_class": "redis.BlockingConnectionPool",
|
||||
},
|
||||
}
|
||||
}
|
||||
# CACHE_MIDDLEWARE_ALIAS
|
||||
# CACHE_MIDDLEWARE_SECONDS
|
||||
# CACHE_MIDDLEWARE_KEY_PREFIX
|
||||
|
||||
CRISPY_TEMPLATE_PACK = "bulma"
|
||||
CRISPY_ALLOWED_TEMPLATE_PACKS = ("bulma",)
|
||||
DJANGO_TABLES2_TEMPLATE = "django-tables2/bulma.html"
|
||||
|
@ -69,6 +87,9 @@ MIDDLEWARE = [
|
|||
"django.contrib.messages.middleware.MessageMiddleware",
|
||||
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
||||
"django_htmx.middleware.HtmxMiddleware",
|
||||
# 'django.middleware.cache.UpdateCacheMiddleware',
|
||||
# 'django.middleware.common.CommonMiddleware',
|
||||
# 'django.middleware.cache.FetchFromCacheMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = "app.urls"
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
{% load static %}
|
||||
{% load has_plan %}
|
||||
{% load cache %}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-GB">
|
||||
{% cache 600 head %}
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
@ -195,8 +197,10 @@
|
|||
</script>
|
||||
<!-- End Piwik Code -->
|
||||
</head>
|
||||
{% endcache %}
|
||||
<body>
|
||||
|
||||
{% cache 600 nav request.user.id %}
|
||||
<nav class="navbar" role="navigation" aria-label="main navigation">
|
||||
<div class="navbar-brand">
|
||||
<a class="navbar-item" href="{% url 'home' %}">
|
||||
|
@ -310,6 +314,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
{% endcache %}
|
||||
<script>
|
||||
let deferredPrompt;
|
||||
const addBtn = document.querySelector('.add-button');
|
||||
|
|
|
@ -43,6 +43,8 @@ services:
|
|||
- ${PORTAINER_GIT_DIR}:/code
|
||||
- ${APP_DATABASE_FILE}:/conf/db.sqlite3
|
||||
- fisk_static:${STATIC_ROOT}
|
||||
volumes_from:
|
||||
- tmp
|
||||
env_file:
|
||||
- stack.env
|
||||
|
||||
|
@ -58,6 +60,8 @@ services:
|
|||
- ${PORTAINER_GIT_DIR}:/code
|
||||
- ${APP_DATABASE_FILE}:/conf/db.sqlite3
|
||||
- fisk_static:${STATIC_ROOT}
|
||||
volumes_from:
|
||||
- tmp
|
||||
env_file:
|
||||
- stack.env
|
||||
|
||||
|
@ -98,24 +102,33 @@ services:
|
|||
volumes:
|
||||
- /var/run/socks
|
||||
|
||||
# redis:
|
||||
# image: redis
|
||||
# command: redis-server /etc/redis.conf
|
||||
# ulimits:
|
||||
# nproc: 65535
|
||||
# nofile:
|
||||
# soft: 65535
|
||||
# hard: 65535
|
||||
# volumes:
|
||||
# - ${PORTAINER_GIT_DIR}/docker/redis.conf:/etc/redis.conf
|
||||
# - redis_data:/data
|
||||
# volumes_from:
|
||||
# - tmp
|
||||
# healthcheck:
|
||||
# test: "redis-cli -s /var/run/redis/redis.sock ping"
|
||||
# interval: 2s
|
||||
# timeout: 2s
|
||||
# retries: 15
|
||||
# For caching
|
||||
redis:
|
||||
image: redis
|
||||
container_name: redis_fisk
|
||||
command: redis-server /etc/redis.conf
|
||||
ulimits:
|
||||
nproc: 65535
|
||||
nofile:
|
||||
soft: 65535
|
||||
hard: 65535
|
||||
volumes:
|
||||
- ${PORTAINER_GIT_DIR}/docker/redis.conf:/etc/redis.conf
|
||||
- fisk_redis_data:/data
|
||||
volumes_from:
|
||||
- tmp
|
||||
healthcheck:
|
||||
test: "redis-cli -s /var/run/socks/redis.sock ping"
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 15
|
||||
|
||||
# pyroscope:
|
||||
# image: "pyroscope/pyroscope:latest"
|
||||
# ports:
|
||||
# - "4040:4040"
|
||||
# command:
|
||||
# - "server"
|
||||
|
||||
networks:
|
||||
default:
|
||||
|
@ -127,3 +140,4 @@ networks:
|
|||
|
||||
volumes:
|
||||
fisk_static: {}
|
||||
fisk_redis_data: {}
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
unixsocket /var/run/redis/redis.sock
|
||||
unixsocket /var/run/socks/redis.sock
|
||||
unixsocketperm 777
|
|
@ -22,3 +22,7 @@ oandapyV20
|
|||
glom
|
||||
elasticsearch
|
||||
git+https://git.zm.is/XF/django-crud-mixins
|
||||
# pyroscope-io
|
||||
# For caching
|
||||
redis
|
||||
hiredis
|
||||
|
|
Loading…
Reference in New Issue