docker nginx cache issue code example

Example: nginx browser caching in docker containers

# docker run -d -p 80:80 -h ntest --name ntest nginx
# docker exec -it -u 0 ntest bash
# ntest# nano /etc/nginx/conf.d/default.conf

# then follow this source digitalocean guide

. . .
# Expires map
map $sent_http_content_type $expires {
    default                    off;
    text/html                  epoch;
    text/css                   max;
    application/javascript     max;
    ~image/                    max;
}

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    expires $expires;
. . .

Tags:

Misc Example