Serve static content from a cookieless domain in NGINX

Very simply one to help anyone out there fix the issue. This does not require a CDN or sub domain, etc like most tutorials.

It’s simply a few lines of code to add to your host file:

location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
expires     max;
fastcgi_hide_header "Set-Cookie";
}

A real example

server {
listen      185.122.57.134:443 ssl http2;
server_name blog.ss88.uk www.blog.ss88.uk;
root        /XXX/XXX/XXX/public_html;
index       index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$args;
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
expires     max;
fastcgi_hide_header "Set-Cookie";
}
}