mirror of
https://git.sdbs.cz/sdbs/pile.git
synced 2025-05-10 00:12:18 +00:00
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.urls import path
|
||||||
|
from django.views.decorators.cache import cache_page
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
from .views import IPFSView, ExternalLinkView
|
from .views import IPFSView, ExternalLinkView
|
||||||
|
@ -10,7 +11,7 @@ urlpatterns = [
|
||||||
path('item/<int:document_id>', views.DocumentView.as_view(), name='document'),
|
path('item/<int:document_id>', views.DocumentView.as_view(), name='document'),
|
||||||
path('label/<int:document_id>', views.LabelView.as_view(), name='label'),
|
path('label/<int:document_id>', views.LabelView.as_view(), name='label'),
|
||||||
path('retrieve/<int:document_id>', views.DocumentWithLabelView.as_view(), name='retrieve'),
|
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('feed', views.RecentlyUploadedFeed()),
|
||||||
path('api/external_links', ExternalLinkView),
|
path('api/external_links', ExternalLinkView),
|
||||||
path('api/ipfs_cids', IPFSView)
|
path('api/ipfs_cids', IPFSView)
|
||||||
|
|
|
@ -24,10 +24,24 @@ SECRET_KEY = os.getenv("SECRET_KEY")
|
||||||
if os.getenv("DEV"):
|
if os.getenv("DEV"):
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
ALLOWED_HOSTS = []
|
ALLOWED_HOSTS = []
|
||||||
|
|
||||||
|
CACHES = {
|
||||||
|
'default': {
|
||||||
|
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else:
|
else:
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
ALLOWED_HOSTS = ["pile.sdbs.cz"]
|
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"))
|
STATIC_PILE = bool(os.getenv("STATIC"))
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
Loading…
Add table
Reference in a new issue