From 1efa9b2166c69f2b2459b1f00e9248c03587528a Mon Sep 17 00:00:00 2001 From: MassiveAtoms Date: Wed, 15 Jul 2020 20:30:04 -0300 Subject: [PATCH] added cache --- .../__pycache__/settings.cpython-38.pyc | Bin 3380 -> 3642 bytes .../CalibreWebCompanion/settings.py | 20 +++++++++++++-- .../library/__pycache__/models.cpython-38.pyc | Bin 10796 -> 10796 bytes .../library/__pycache__/urls.cpython-38.pyc | Bin 1227 -> 1291 bytes .../library/__pycache__/views.cpython-38.pyc | Bin 7015 -> 7015 bytes CalibreWebCompanion/library/models.py | 24 +----------------- .../library/templates/base.html | 14 +++++----- CalibreWebCompanion/library/urls.py | 2 +- CalibreWebCompanion/library/views.py | 1 + 9 files changed, 29 insertions(+), 32 deletions(-) diff --git a/CalibreWebCompanion/CalibreWebCompanion/__pycache__/settings.cpython-38.pyc b/CalibreWebCompanion/CalibreWebCompanion/__pycache__/settings.cpython-38.pyc index 20b35cafbec89ff4b7bef263d7470e7cbe305d04..aaa27cd4fccbb81cd6770d624e6005c69aa1f86e 100644 GIT binary patch delta 662 zcmYjOOHUI~6z-kQbf!Z~OQAeVDZZfgg(!+rlrk11LTjKk<}M`Te3$7!+tEHk(hWOZ z7#F4+7hOo=FQBfB@rQJ&i9f-_h2pdj;<@=w&Uena=X^K!^Z1uQB=2_1Hp_m#_3Xa! z*=#?$%@X5Jv)YxPf_HFbHn8cx(L#ZqZRJTy)<)=5VLQU1UToo@eg1 zI68)VSkgH)OxYjh+$tX>tv9>!9kj+1`J}|5CVE<~S?2a+PMC z9MgNDE_H}Om;wh=Aux4*`Z2&g9|oBpL*2AMT|}ls4FVa>VT@oDS&SiPI2r``w!ouT6vwTMhb6qZXdA>mmfkm;vVyLhq^`rmP4))?uAAG+HCLz~9bTNAn{Ubzk*t`SCnRmww0+Cc nibTxthn{B4Pv?#Ak+*_VwkL>4=(j)x$-LET_Afy*KlGg+O($e2 diff --git a/CalibreWebCompanion/CalibreWebCompanion/settings.py b/CalibreWebCompanion/CalibreWebCompanion/settings.py index e25b9fa..7484635 100644 --- a/CalibreWebCompanion/CalibreWebCompanion/settings.py +++ b/CalibreWebCompanion/CalibreWebCompanion/settings.py @@ -19,6 +19,20 @@ CALIBRE_DIR = os.path.abspath( EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' + +# optimisation stuff +CONN_MAX_AGE = 60 * 5 + +CACHES = { + 'default': { + 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', + 'LOCATION': 'unique-snowflake', + "TIMEOUT" : 60 * 5, + + } +} + + # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.0/howto/static-files/ @@ -33,7 +47,7 @@ STATIC_URL = '/static/' # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ -# SECURITY WARNING: keep the secret key used in production secret! +# SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'u(8^+rb%rz5hsx4v^^y(ul7g(4n7a8!db@s*9(m5cs*2_ppy8+' @@ -43,7 +57,7 @@ INTERNAL_IPS = [ '127.0.0.1', # ... ] -# Don't change things beyond this + # SECURITY WARNING: don't run with debug turned on in production! @@ -83,6 +97,7 @@ INSTALLED_APPS = [ MIDDLEWARE = [ 'debug_toolbar.middleware.DebugToolbarMiddleware', # DEBUG purposes + 'django.middleware.cache.UpdateCacheMiddleware', # cache 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', @@ -90,6 +105,7 @@ MIDDLEWARE = [ 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'django.middleware.cache.FetchFromCacheMiddleware', # cache ] ROOT_URLCONF = 'CalibreWebCompanion.urls' diff --git a/CalibreWebCompanion/library/__pycache__/models.cpython-38.pyc b/CalibreWebCompanion/library/__pycache__/models.cpython-38.pyc index 4daacd3707a811db84cde2a93468e14108b44ebd..adcae8b0a8596265973aab5aedbd5a8e1afd2cbb 100644 GIT binary patch delta 23 dcmZ1zvL=Ktl$V!_0SIy?^2cx0-N+}W1prBl1>67t delta 23 dcmZ1zvL=Ktl$V!_0SJUR`QuONZ{(BH0sukB1rY!M diff --git a/CalibreWebCompanion/library/__pycache__/urls.cpython-38.pyc b/CalibreWebCompanion/library/__pycache__/urls.cpython-38.pyc index 9f8441360f9f4bb496f5e1fb54633ae0b6c017c6..199ec700a59290a127d3bc4ef5d50faabd84ac33 100644 GIT binary patch delta 432 zcmXZYOHRW;3;@s!`Ly{=(ofm~X$q7gQ6Xi?hGQT$*;G*`3RH!lNee4fi6sb$Di?qQ zu<9|mK`y}+a4p-5v7fD3_}6^5_zmZl0`dCh&Hgq#WS5(ZU@a7(Ewp<*)|rwqp=avc z_-cGB!VrxQ6{HE$L@`M$5EI2FaX>5-PU3>tC>}`*#6fA3bU@Y|sY~PoxhOr7K8S}h zAlV0Lp&XDLg0xWrk|9V3B_tVvbWx5-jzRn}(h1QRs3%T$UGBwwF}YTzXI0Dscgkuj zP14(J_L$_^cEvu~)u6V;JbB2AXeAe=+=JWJiqv*bNQ0-l?756YmKHKu7P5@+52Fg4_;2{9}OB8QL)%aKS6lCm6& zv>{cNjz||$W9f;UKrBnPmrK_N)!kqhr|EUWosPZX*>?A+A^qyv-P8S+_Q8LC$X^zl f4_Xm5i%hjPH%d`p(avo#(XZhEYeI=%{OR65Fj84u diff --git a/CalibreWebCompanion/library/__pycache__/views.cpython-38.pyc b/CalibreWebCompanion/library/__pycache__/views.cpython-38.pyc index 8fe7e250f71f2dfb4dbecf43e208d9b726409013..bde1878620dfcd4db38c9d85a6c83d33b0c7bc7c 100644 GIT binary patch delta 216 zcmaEE_S}p&l$V!_0SF?x_~Q*W@~&cL@%3Ns=OydH6CJqc@lFZDnN4o~$EK%b2lwl>ksl^W+DDlNf6!7Ymg!R&9PIq|L}U zVX~M=KVuh2*DjHG#`eupq8f~hb0<5C^)ODKd_k;$amr>#aXm)Hm6Ho3`WY8bk}PIi Qu(?F?5+ftaWOr!=0C5{atN;K2 delta 216 zcmaEE_S}p&l$V!_0SNXA^T+FNG`W$xkuhvDGmj}FWAbE6 z-hGU*lO#nZ^YCRdMr|(R+seq8HCacXmN9+vDgmI9rpXTkCo$GcE*2_dtla!cNSl$d zf3lcJKVv6I*DjHG# + + - {% if user.is_authenticated %} {% block content %} {% endblock %} {% else %} diff --git a/CalibreWebCompanion/library/urls.py b/CalibreWebCompanion/library/urls.py index 5271440..e66bf6d 100644 --- a/CalibreWebCompanion/library/urls.py +++ b/CalibreWebCompanion/library/urls.py @@ -1,6 +1,6 @@ from django.urls import path from . import views - +from django.views.decorators.cache import cache_page urlpatterns = [ diff --git a/CalibreWebCompanion/library/views.py b/CalibreWebCompanion/library/views.py index 146e306..dbb821d 100644 --- a/CalibreWebCompanion/library/views.py +++ b/CalibreWebCompanion/library/views.py @@ -10,6 +10,7 @@ from django.contrib.auth import login from django.contrib.auth.decorators import login_required + @login_required def index(request): return render(request, 'accounts/index.html')