Skip to content

Commit 63aa60e

Browse files
committed
caching, compression and other small speed optimization
1 parent c928971 commit 63aa60e

File tree

4 files changed

+43
-5
lines changed

4 files changed

+43
-5
lines changed

deploy-tools/setup-ubuntu16.04.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ apt -y install sqlite3 # for easier database imports
2828

2929
#### Apache ####
3030
apt -y install apache2
31+
a2enmod headers
32+
a2enmod expires
3133

3234
# Next libapache2-mod-wsgi-py3 works with the built-in Python 3.5, so we have to manually build
3335
# a newer version.

deploy-tools/vhost.conf.sample

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,41 @@
1919
</Files>
2020
</Directory>
2121

22+
<ifModule mod_headers.c>
23+
Header append Cache-Control "public"
24+
</ifModule>
25+
26+
<ifModule mod_expires.c>
27+
ExpiresActive On
28+
29+
# 1 day, all expire at the same time
30+
ExpiresByType application/json M86400
31+
ExpiresByType text/html M86400
32+
33+
# 1 week
34+
ExpiresByType text/css A604800
35+
ExpiresByType application/javascript A604800
36+
37+
# 1 year
38+
ExpiresByType image/gif A31536000
39+
ExpiresByType image/png A31536000
40+
ExpiresByType image/jpeg A31536000
41+
42+
# 6 months
43+
ExpiresByType audio/aac A15552000
44+
ExpiresByType audio/ogg A15552000
45+
ExpiresByType audio/opus A15552000
46+
</ifModule>
47+
48+
<IfModule mod_deflate.c>
49+
<IfModule mod_filter.c>
50+
# "application/json" compression is not enabled by default. Since adding a filter here completely overrides
51+
# the default configuration, we list all desired types explicitly.
52+
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
53+
AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript application/json
54+
</IfModule>
55+
</IfModule>
56+
2257
ErrorLog ${APACHE_LOG_DIR}/dimmu-saurus.errors.log
2358
CustomLog ${APACHE_LOG_DIR}/dimmu-saurus.access.log combined
2459
</VirtualHost>

src/demo.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616

1717
<link
1818
rel="stylesheet"
19-
href="https://fonts.googleapis.com/css?family=Griffy|Noto+Sans:400,400i,700,700i&amp;display=swap&amp;subset=cyrillic">
19+
href="https://fonts.googleapis.com/css?family=Griffy|Noto+Sans:400,400i,700,700i&amp;display=swap&amp;subset=cyrillic&amp;display=swap">
2020

2121
<link
2222
rel="stylesheet"
2323
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css"
2424
integrity="sha256-+N4/V/SbAFiW1MPBCXnfnP9QSN3+Keu+NlB+0ev/YKQ="
2525
crossorigin="anonymous">
2626

27-
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.2/axios.min.js"></script>
27+
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.2/axios.min.js" async="async"></script>
2828

2929
<script>
3030
function isOldBrowser() {
@@ -45,6 +45,7 @@
4545

4646

4747
var js = document.createElement('script');
48+
js.defer = 'defer';
4849

4950
if (isOldBrowser()) {
5051
js.src = 'ds.legacy.js';
@@ -58,7 +59,6 @@
5859
}
5960

6061
document.head.appendChild(js);
61-
6262
</script>
6363
</head>
6464

src/py/main/templates/main/__root.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@
3030

3131
<link
3232
rel="stylesheet"
33-
href="https://fonts.googleapis.com/css?family=Griffy|Noto+Sans:400,400i,700,700i&amp;display=swap&amp;subset=cyrillic">
33+
href="https://fonts.googleapis.com/css?family=Griffy|Noto+Sans:400,400i,700,700i&amp;display=swap&amp;subset=cyrillic&amp;display=swap">
3434

3535
<link
3636
rel="stylesheet"
3737
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css"
3838
integrity="sha256-+N4/V/SbAFiW1MPBCXnfnP9QSN3+Keu+NlB+0ev/YKQ="
3939
crossorigin="anonymous">
4040

41-
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.2/axios.min.js"></script>
41+
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.2/axios.min.js" async="async"></script>
4242

4343
<script>
4444
AJAXIFY_EXCLUDE = [
@@ -69,6 +69,7 @@
6969

7070

7171
var js = document.createElement('script');
72+
js.defer = 'defer';
7273

7374
if (isOldBrowser()) {
7475
js.src = '{% static "ds.legacy.min.js" %}';

0 commit comments

Comments
 (0)