Decorate Javascript i18n with a last_modified header
Every request to horizon fetches the js i18n catalog because it has no caching information, which is a huge overhead, given that the server side is also not caching anything. Follow advice in Django documentation on how to inject a last modified header https://docs.djangoproject.com/en/1.11/topics/i18n/translation/#note-on-performance Change-Id: I96b849836f738c8d42c23cc47f4e575d7eb1af71
This commit is contained in:
parent
d0297a5ed0
commit
ecdeff4d85
@ -19,6 +19,8 @@
|
||||
from django.conf import settings
|
||||
from django.conf.urls import include
|
||||
from django.conf.urls import url
|
||||
from django.utils import timezone
|
||||
from django.views.decorators.http import last_modified
|
||||
from django.views.generic import TemplateView
|
||||
from django.views import i18n
|
||||
|
||||
@ -29,10 +31,13 @@ urlpatterns = [
|
||||
url(r'^home/$', views.user_home, name='user_home')
|
||||
]
|
||||
|
||||
last_modified_date = timezone.now()
|
||||
|
||||
# Client-side i18n URLconf.
|
||||
urlpatterns.extend([
|
||||
url(r'^i18n/js/(?P<packages>\S+?)/$',
|
||||
i18n.JavaScriptCatalog.as_view(),
|
||||
last_modified(lambda req, **kw: last_modified_date)(
|
||||
i18n.JavaScriptCatalog.as_view()),
|
||||
name='jsi18n'),
|
||||
url(r'^i18n/setlang/$',
|
||||
i18n.set_language,
|
||||
|
Loading…
Reference in New Issue
Block a user