Mins / TuxLite

A complete LAMP and LNMP setup script for Debian or Ubuntu
http://tuxlite.com
253 stars 112 forks source link

Add longer browser cache expiration #35

Closed matrixik closed 10 years ago

matrixik commented 10 years ago

Maybe you could add longer browser cache expiration for static files? https://developers.google.com/speed/docs/best-practices/caching?csw=1#LeverageBrowserCaching

For Nginx: Based on http://mesmor.com/2012/02/25/web-optimization-leverage-browser-caching/ :

location ~* \.(js|css|png|jpg|jpeg|gif|ico)(\?ver=[0-9.]+)?$ {
        expires 1y;
}

or https://github.com/rtCamp/easyengine/blob/master/etc/nginx/common/locations.conf#L17 :

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)$ {
    access_log off;
    log_not_found off;
    expires 1y;
}

Best regards