nginxcache-controlexpires-headershopware

How to solve Google Page Speed: "expiration not specified"


Analyzing an online shop (Shopware) with GooglePageSpeed results in many "expiration not specified"-Lines on every image.

enter image description here

I am wondering about because the webserver (nginx) adds Last-Modified-Timestamps and ETAG headers to the response of all images, resulting in an expected 304-Response on the second request.

enter image description here

Is ETAG/LastModified not supported by Google Page Speed?

I will provide the appropriate parts of the nginx-configuration:

location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
  expires 1M;
  access_log off;
  add_header Cache-Control "public";
}

## All static files will be served directly.
location ~* ^.+\.(?:css|cur|js|jpe?g|gif|ico|png|html|xml)$ {
    ## Defining rewrite rules
    rewrite files/documents/.* /engine last;
    rewrite backend/media/(.*) /media/$1 last;

    expires 1w;
    add_header Cache-Control "public, must-revalidate, proxy-revalidate";

    access_log off;
    # The directive enables or disables messages in error_log about files not found on disk.
    log_not_found off;

    tcp_nodelay off;
    ## Set the OS file cache.
    open_file_cache max=3000 inactive=120s;
    open_file_cache_valid 45s;
    open_file_cache_min_uses 2;
    open_file_cache_errors off;

    ## Fallback to shopware
    ## comment in if needed
    #try_files $uri @shopware;
}

Is there anythong wrong or missing?


Solution

  • Finally we've found out, that there was another expire-statement in the vhost-config. Reduce both to one single statement solved our issue