Want to subscribe to topics you're interested in?
Become a Member

Nginx Leverage browser caching

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by Alex, Sep 19, 2014.

  1. Alex

    Alex New Member

    24
    5
    3
    Jun 18, 2014
    Ratings:
    +5
    Local Time:
    2:25 AM
    1.4.6
    Gday, just trying to get browser caching working.

    My domain.com.conf contains: include /usr/local/nginx/conf/staticfiles.conf;

    The staticfiles.conf contains:
    location ~* \.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso|eot|svg|ttf|woff)$ {
    gzip_static off;
    add_header Pragma public;
    add_header Cache-Control "public, must-revalidate, proxy-revalidate";
    access_log off;
    expires 30d;
    break;
    }

    location ~* \.(html|htm|txt|js|css)$ {
    add_header Pragma public;
    add_header Cache-Control "public, must-revalidate, proxy-revalidate";
    access_log off;
    expires 30d;
    break;
    }


    But still the js is not being cached so GTmetrix etc is having a whinge...


    Any ideas?

    Cheers
     
  2. eva2000

    eva2000 Administrator Staff Member

    53,558
    12,135
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,678
    Local Time:
    1:25 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    @Alex

    Should work unless gtmetrix is complaining about 3rd party urls which you would not have any control over

    what version of Centmin Mod you using ?
     
  3. Alex

    Alex New Member

    24
    5
    3
    Jun 18, 2014
    Ratings:
    +5
    Local Time:
    2:25 AM
    1.4.6
    Centmin Mod 1.2.3-eva2000.01

    Ah... my bad... yes of course... they were 3rd party urls... google analytics, jquery etc...
     
  4. eva2000

    eva2000 Administrator Staff Member

    53,558
    12,135
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,678
    Local Time:
    1:25 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  5. Alex

    Alex New Member

    24
    5
    3
    Jun 18, 2014
    Ratings:
    +5
    Local Time:
    2:25 AM
    1.4.6
    Haha yeah, too scared to update, thinking it might break something...
     
  6. eva2000

    eva2000 Administrator Staff Member

    53,558
    12,135
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,678
    Local Time:
    1:25 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  7. Alex

    Alex New Member

    24
    5
    3
    Jun 18, 2014
    Ratings:
    +5
    Local Time:
    2:25 AM
    1.4.6
    yeah good idea, thanks :)