Skip to content

Commit

Permalink
Adding further cache optimizations, gzip compression, and minifying js
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Nov 15, 2024
1 parent 5b0d005 commit 041178a
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
4 changes: 1 addition & 3 deletions crank/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@
import os
from pathlib import Path

from django.conf.global_settings import STATICFILES_DIRS, CACHE_MIDDLEWARE_SECONDS
from django.contrib.staticfiles.storage import ManifestStaticFilesStorage
from dotenv import load_dotenv
from opentelemetry.instrumentation.django import DjangoInstrumentor
from tests.test_settings import MANIFEST_LOADER

load_dotenv()
DjangoInstrumentor().instrument(is_sql_commentor_enabled=True)
Expand Down Expand Up @@ -92,6 +89,7 @@
)

MIDDLEWARE = [
'django.middleware.gzip.GZipMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
Expand Down
2 changes: 1 addition & 1 deletion crank/templatetags/socialapp_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ def get_cached_social_app(provider):
cache_key = f'social_app_{provider}'
social_app = cache.get(cache_key)
if not social_app:
social_app = SocialApp.objects.filter(provider=provider).first()
social_app = SocialApp.objects.filter(provider=provider).prefetch_related('sites').first()
cache.set(cache_key, social_app, timeout=settings.CACHE_MIDDLEWARE_SECONDS)
return social_app
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"jest-environment-jsdom": "^29.7.0",
"jest-fetch-mock": "^3.0.3",
"nodemon": "^3.1.7",
"terser-webpack-plugin": "^5.3.10",
"ts-jest": "^29.2.5",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
Expand Down
4 changes: 3 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const path = require('path');
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
const {WebpackManifestPlugin} = require('webpack-manifest-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const options = {};


Expand All @@ -24,7 +25,8 @@ module.exports = {
},
mode: 'production',
optimization: {
minimize: false
minimize: true,
minimizer: [new TerserPlugin()],
},
plugins: [
new CleanWebpackPlugin(options),
Expand Down

0 comments on commit 041178a

Please sign in to comment.