server {
    listen          {{port}};
    server_name     {% for alias in aliases %}{{alias}} {% endfor %};
    root            {{root}};
    error_log       {{error_log}};
    access_log      {{access_log}};

    location ~*  \.(jpg|jpeg|png|gif|ico|css|js|svg|woff)$ {
        expires 365d;
    }

    {% for config in configs %}
        include         {{config}};
    {% endfor %}
}

server {
    listen          {{port}};
    server_name     {% for alias in aliases %}{{alias}} {% endfor %};
    root            {{root}};
    error_log       {{error_log}};
    access_log      {{access_log}};

    location ~*  \.(jpg|jpeg|png|gif|ico|css|js|svg|woff)$ {
        expires 365d;
        try_files $uri /app.php$is_args$args;
    }

    {% for config in configs %}
        include         {{config}};
    {% endfor %}
}

Add fallback to app.php for images which are not in the cache
Add fallback to app.php for images which are not in the cache