Skip to content

Commit

Permalink
Merge pull request #100 from schemen/dev
Browse files Browse the repository at this point in the history
Add caching and compression to serve static files
  • Loading branch information
schemen authored Jul 25, 2023
2 parents ff1fcb2 + 7b0798b commit ddf9b6e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.11.0(2023-07-25)

### Improvement
* Implement Caching and Cache Busting


## 1.10.1(2023-07-19)

### Updates
Expand Down
4 changes: 2 additions & 2 deletions dndtools/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/

STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
STATIC_URL = '/static/'

STATIC_ROOT = os.path.join(BASE_DIR, 'static')

AUTH_USER_MODEL = 'paperminis.User'
Expand Down Expand Up @@ -189,4 +189,4 @@
messages.SUCCESS: 'alert-success',
messages.WARNING: 'alert-warning',
messages.ERROR: 'alert-danger',
}
}
21 changes: 19 additions & 2 deletions nginx/djangonginx.conf
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
server {
listen 80;
server_name localhost;
real_ip_header X-real-IP;

# compression
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

# serve static files
location /static/ {
sendfile on;
expires max; # change this to a value that suits your needs
add_header Cache-Control "public";
alias /static/;
}

# pass requests for dynamic content to gunicorn
location / {
proxy_pass http://app:8080;
proxy_pass http://monsterforge:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
2 changes: 1 addition & 1 deletion paperminis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = '1.10.1'
__version__ = '1.11.0'
VERSION = __version__ # synonym

0 comments on commit ddf9b6e

Please sign in to comment.