Adding Expired header to make loading faster

Add the Expires directives inside the http block or a specific server block.?
Using Ghost version 5.82.11 on Nginx

This gives an error and dont know why.

location ~* .(jpg|jpeg|gif|png|css|js|ico|pdf|svg|woff|woff2|ttf|otf)$ {
expires 1y;
add_header Cache-Control “public”;
}

    location ~* \.(html)$ {
        expires 1h;
        add_header Cache-Control "public, must-revalidate";
    }

What error does it give?

What you posted contains smart quotes not regular quotes.

If you actually have smart quotes in your Nginx config, that would cause an error.

This is the result after reloading

May 19 22:26:38 localhost nginx[293642]: nginx: [emerg] “location” directive is not allowed here in /etc/nginx/nginx.co> May 19 22:26:38 localhost systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE May 19 22:26:38 localhost systemd[1]: Reload failed for A high performance web server and a reverse proxy server.

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
worker_connections 768;
# multi_accept on;
}

http {
##
# Basic Settings
##

sendfile on;
tcp_nopush on;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# Expires headers configuration
##

# Define custom expiration for various file types
location ~* \.(jpg|jpeg|gif|png|css|js|ico|pdf|svg|woff|woff2|ttf|otf)$ {
    expires 1y;
    add_header Cache-Control "public";
}

location ~* \.(html)$ {
    expires 1h;
    add_header Cache-Control "public, must-revalidate";
}

# Other configurations such as server, upstream, etc.
...

}