1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice
  2. Dear Pleskians, please read this carefully! New attachments and other rules Thank you!
    Dismiss Notice
  3. Dear Pleskians, I really hope that you will share your opinion in this Special topic for chatter about Plesk in the Clouds. Thank you!
    Dismiss Notice

Resolved Leverage browser caching

Discussion in 'Plesk Onyx for Linux' started by dyrer, Dec 5, 2017.

Tags:
  1. dyrer

    dyrer Basic Pleskian

    26
     
    Joined:
    Mar 27, 2007
    Messages:
    51
    Likes Received:
    0
    Location:
    Greece
    hello i have the the code bellow in Serve static files directly by nginx directives
    PHP:
    gzip  on;
    gzip_http_version 1.0;
    gzip_comp_level 9;
    gzip_min_length 1100;
    gzip_buffers     4 8k;
    gzip_proxied any;
    gzip_types
    # text/html is always compressed by HttpGzipModule
    text/css
    text
    /javascript
    text
    /xml
    text
    /plain
    text
    /x-component
    application
    /javascript
    application
    /json
    application
    /xml
    application
    /rss+xml
    font
    /truetype
    font
    /opentype
    application
    /vnd.ms-fontobject
    image
    /svg+xml;

    gzip_static on;

    gzip_proxied        expired no-cache no-store private auth;
    gzip_disable        "MSIE [1-6]\.";
    gzip_vary           on;

    location ~* \.(txt|xml|js)$ {
        
    expires 8d;
    }

    location ~* \.(css)$ {
        
    expires 8d;
    }

    location ~* \.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav|mp4|m4v|ogg|webm|aac|eot|ttf|otf|woff|svg)$ {
        
    expires 8d;
    }

    location ~* \.(jpg|jpeg|png|gif|swf|webp)$ {
        
    expires 8d;
    }
    but still GTMetrix result shows expiration not specified for gif, png etc


    How can fix that?
    Thanks in advance
     
  2. virtubox

    virtubox Regular Pleskian Plesk Guru

    19
    60%
    Joined:
    May 4, 2016
    Messages:
    204
    Likes Received:
    70
    Location:
    France
    Hello @dyrer ,
    it's not required to enable the settings "serve static files directly with Nginx" to apply addtional directives :

    GTmetrix require to allow browser cache for at least 30 days to validate this rule.

    Here the configuration used on my servers :
    Code:
     
    # Enable Gzip compression
    gzip on;
    gzip_disable "msie6";
     gzip_vary on;
     gzip_proxied any;
     gzip_comp_level 6;
     gzip_buffers 16 8k;
     gzip_http_version 1.1;
     gzip_types
     application/atom+xml
     application/javascript
     application/json
     application/rss+xml
     application/vnd.ms-fontobject
     application/x-font-ttf
     application/x-web-app-manifest+json
     application/xhtml+xml
     application/xml
     font/opentype
     image/svg+xml
     image/x-icon
     text/css
     text/plain
     text/x-component
     text/xml
     text/javascript;
    
    # Cache static files
    location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|swf|webp)$ {
      add_header "Access-Control-Allow-Origin" "*";
      access_log off;
      log_not_found off;
      expires 30d;
    }
    |/code}
     
    trialotto likes this.
  3. dyrer

    dyrer Basic Pleskian

    26
     
    Joined:
    Mar 27, 2007
    Messages:
    51
    Likes Received:
    0
    Location:
    Greece
Loading...