Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
9
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
Julien Enselme
django-pwa
Commits
822ae00e
Commit
822ae00e
authored
Feb 25, 2020
by
Julien Enselme
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add view to easily fill the dynamic cache
parent
52c1ca9b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
0 deletions
+15
-0
djangopwa/apps/pwa/views.py
djangopwa/apps/pwa/views.py
+5
-0
djangopwa/templates/pwa/fill_dynamic_cache.html
djangopwa/templates/pwa/fill_dynamic_cache.html
+9
-0
djangopwa/urls.py
djangopwa/urls.py
+1
-0
No files found.
djangopwa/apps/pwa/views.py
View file @
822ae00e
...
...
@@ -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'
...
...
djangopwa/templates/pwa/fill_dynamic_cache.html
0 → 100644
View file @
822ae00e
{% 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 %}
djangopwa/urls.py
View file @
822ae00e
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment