cache image files for 6 hours
This commit is contained in:
parent
efcac5f541
commit
dfa576fd62
2 changed files with 16 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
|||
from django.urls import path
|
||||
from django.views.decorators.cache import cache_page
|
||||
|
||||
from . import views
|
||||
from .views import IPFSView, ExternalLinkView
|
||||
|
@ -10,7 +11,7 @@ urlpatterns = [
|
|||
path('item/<int:document_id>', views.DocumentView.as_view(), name='document'),
|
||||
path('label/<int:document_id>', views.LabelView.as_view(), name='label'),
|
||||
path('retrieve/<int:document_id>', views.DocumentWithLabelView.as_view(), name='retrieve'),
|
||||
path('image/<int:document_id>', views.BrandedImageView.as_view(), name='image'),
|
||||
path('image/<int:document_id>', cache_page(60 * 60 * 6)(views.BrandedImageView.as_view()), name='image'),
|
||||
path('feed', views.RecentlyUploadedFeed()),
|
||||
path('api/external_links', ExternalLinkView),
|
||||
path('api/ipfs_cids', IPFSView)
|
||||
|
|
|
@ -24,10 +24,24 @@ SECRET_KEY = os.getenv("SECRET_KEY")
|
|||
if os.getenv("DEV"):
|
||||
DEBUG = True
|
||||
ALLOWED_HOSTS = []
|
||||
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
|
||||
}
|
||||
}
|
||||
|
||||
else:
|
||||
DEBUG = False
|
||||
ALLOWED_HOSTS = ["pile.sdbs.cz"]
|
||||
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
|
||||
'LOCATION': '/var/tmp/pile_cache',
|
||||
}
|
||||
}
|
||||
|
||||
STATIC_PILE = bool(os.getenv("STATIC"))
|
||||
|
||||
# Application definition
|
||||
|
|
Loading…
Reference in a new issue