Commit 822ae00e authored by Julien Enselme's avatar Julien Enselme

Add view to easily fill the dynamic cache

parent 52c1ca9b
......@@ -24,6 +24,7 @@ def my_page(request):
'Say bye': reverse('say_something', kwargs={'key': 'bye'}),
'Say something invalid': reverse('say_something', kwargs={'key': 'invalid'}),
'Response in random time': reverse('random_response'),
'Fill dynamic cache': reverse('fill_dynamic_cache', kwargs={'id': 1}),
}
return render(request, 'pwa/my_page.html', context={'routes': routes})
......@@ -49,6 +50,10 @@ def random_response(request):
return render(request, 'pwa/random_response.html', context={'response_time': response_time})
def fill_dynamic_cache(request, id):
return render(request, 'pwa/fill_dynamic_cache.html', context={'id': id})
class ServiceWorkerView(TemplateView):
template_name = 'sw.js'
content_type = 'application/javascript'
......
{% extends 'base.html' %}
{% block title %}Page n°{{ id }}{% endblock %}
{% block body %}
<p>This is page {{ id }} of the site. It's mostly meant to fill the cache.</p>
<p>Change the number in the URL to see another page.</p>
{% endblock %}
......@@ -27,6 +27,7 @@ urlpatterns = [
path('offline/', pwa_views.offline, name='offline'),
path('say-something/<str:key>', pwa_views.say_something, name='say_something'),
path('random-response', pwa_views.random_response, name='random_response'),
path('fill-dynamic-cache/<int:id>', pwa_views.fill_dynamic_cache, name='fill_dynamic_cache'),
# The service worker cannot be in /static because its scope will be limited to /static.
# Since we want it to have a scope of the full application, we rely on this TemplateView
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment