Skip to content

Commit

Permalink
⚡️(frontend) add caching headers for static assets in Nginx config
Browse files Browse the repository at this point in the history
Configured Nginx to set caching headers for static assets by adding
a location block to match common static file extensions and set
an expiration time of 30 days.

It should result in faster loading times, reduced bandwidth usage,
and a more efficient and responsive user experience.

Wdyt @manuhabitela?
  • Loading branch information
lebaudantoine committed Jul 15, 2024
1 parent eac107a commit 0a9e077
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/frontend/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ server {

root /usr/share/nginx/html;

# Serve static files with caching
location ~* ^/assets/.*\.(css|js|json|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 30d;
add_header Cache-Control "public, max-age=2592000";
}

# Serve static files
location / {
try_files $uri $uri/ /index.html;
Expand All @@ -15,5 +21,4 @@ server {

# Optionally, handle 404 errors by redirecting to index.html
error_page 404 =200 /index.html;

}

0 comments on commit 0a9e077

Please sign in to comment.