️(frontend) add caching headers for static assets in Nginx config

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?
This commit is contained in:
antoine lebaud
2024-07-11 20:18:24 +02:00
committed by aleb_the_flash
parent eac107aac6
commit 0a9e077f04

View File

@@ -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;
@@ -15,5 +21,4 @@ server {
# Optionally, handle 404 errors by redirecting to index.html
error_page 404 =200 /index.html;
}