{"id":7158,"date":"2017-12-18T17:28:12","date_gmt":"2017-12-18T17:28:12","guid":{"rendered":"http:\/\/hostileblog.com\/?p=5708"},"modified":"2020-05-30T21:31:28","modified_gmt":"2020-05-31T01:31:28","slug":"nginx-gzip_static","status":"publish","type":"post","link":"https:\/\/www.carnaghan.com\/nginx-gzip_static\/","title":{"rendered":"Nginx gzip_static: What it does and how to use it?"},"content":{"rendered":"

\"NGINX<\/p>\n

Like other top\u00a0web servers, Nginx lets webmasters enable Gzip compression for their websites. It can compress scripts and stylesheets in a web page on the fly. The Gzip file’s size is significantly lower than the original file.\u00a0Nginx supports 9 Gzip compression levels.1 is the lowest and 9 is the highest. To gzip a file, Nginx will use invoke a function and the\u00a0function will use system resources during the file conversion process.\u00a0The function will take few milliseconds\u00a0to execute.<\/p>\n

What is the benefit of Gzipping scripts and stylesheets?<\/h4>\n

Gzipping content improves the performance of the website<\/a>, but it increases the load on a web server. If you have got a popular site that receives tons of direct visitors, you can reduce the cost of hosting by compressing scripts.<\/p>\n

As in real life, even a fraction of a second can make a huge difference on the Internet. According to renowned SEO experts, if e-commerce site’s loading speed increases by a second, the customers will ditch the site or may not make any purchase. Google, the world’s largest search engines consider page speed as one of its search engine ranking signals.<\/p>\n

Gzip_static is a module which makes Nginx serve precompressed GZIP files instead of compressing files on the fly. Along with the FastCGI cache, GS is one of the top features of Nginx.<\/p>\n

How to use Gzip static module?<\/h3>\n

Step 1:<\/strong><\/p>\n

Nginx will search for the Gzip files in the directory. If it doesn’t find one, the web server will covert CSS\/js files into Gzip. If you want to use the Gzip static module, the first thing you should do is create gzip versions of the static assets on your site (excluding images, and server-side code files). To do so, you can use the default Gzip tool in Linux OS i.e. Gunzip. For better compression and to save more bandwidth, you can use Google Brotli<\/a> or Zopfli<\/a> to\u00a0generate Gzip files.<\/p>\n

Step2: (Very important)<\/strong><\/p>\n

Make sure that Nginx has the permission to access the newly generated Gzip file. If you don’t assign this permission to Nginx, won’t send the Gzipped file to the client browser and search bots will report HTTP 500 error in the webmaster consoles.<\/p>\n

Modify the below command’s last 5 words as per your requirements, change the Nginx user and run the command<\/p>\n

chmod -R nginx_user:nginx_user directory path or file name<\/code><\/p>\n

Step 3:<\/strong><\/p>\n

Add the following file to the block in your website’s Nginx configuration file where you’ve set expiry time for JS\/CSS files<\/p>\n

gzip_static on;<\/code><\/p>\n

Step 4:<\/strong><\/p>\n

Restart the web server. That’s it! To see whether Gzip_static is working on your server or not, refer this answer<\/a> on StackOverflow.<\/p>\n","protected":false},"excerpt":{"rendered":"

Like other top\u00a0web servers, Nginx lets webmasters enable Gzip compression for their websites. It can compress scripts and stylesheets in a web page on the fly. The Gzip file’s size is significantly lower than the original file.\u00a0Nginx supports 9 Gzip compression levels.1 is the lowest and 9 is the highest. To gzip a file, Nginx […]<\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[11413,7038],"post_series":[],"yoast_head":"\nNginx gzip_static: What it does and how to use it? - Ian Carnaghan<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.carnaghan.com\/nginx-gzip_static\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Nginx gzip_static: What it does and how to use it? - Ian Carnaghan\" \/>\n<meta property=\"og:description\" content=\"Like other top\u00a0web servers, Nginx lets webmasters enable Gzip compression for their websites. It can compress scripts and stylesheets in a web page on the fly. The Gzip file’s size is significantly lower than the original file.\u00a0Nginx supports 9 Gzip compression levels.1 is the lowest and 9 is the highest. To gzip a file, Nginx […]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.carnaghan.com\/nginx-gzip_static\/\" \/>\n<meta property=\"og:site_name\" content=\"Ian Carnaghan\" \/>\n<meta property=\"article:published_time\" content=\"2017-12-18T17:28:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-05-31T01:31:28+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.carnaghan.com\/wp-content\/uploads\/2017\/12\/NGINX-logo.jpg\" \/>\n<meta name=\"author\" content=\"Pramod\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@icarnaghan\" \/>\n<meta name=\"twitter:site\" content=\"@icarnaghan\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Pramod\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.carnaghan.com\/nginx-gzip_static\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.carnaghan.com\/nginx-gzip_static\/\"},\"author\":{\"name\":\"Pramod\",\"@id\":\"https:\/\/www.carnaghan.com\/#\/schema\/person\/f52a97a0d4f7b309922ab0381d337bbb\"},\"headline\":\"Nginx gzip_static: What it does and how to use it?\",\"datePublished\":\"2017-12-18T17:28:12+00:00\",\"dateModified\":\"2020-05-31T01:31:28+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.carnaghan.com\/nginx-gzip_static\/\"},\"wordCount\":443,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/www.carnaghan.com\/#\/schema\/person\/c689c24d516c51968a88b628860740a5\"},\"image\":{\"@id\":\"https:\/\/www.carnaghan.com\/nginx-gzip_static\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/www.carnaghan.com\/wp-content\/uploads\/2017\/12\/NGINX-logo.jpg\",\"keywords\":[\"Affiliate\",\"Nginx\"],\"articleSection\":[\"Coding\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.carnaghan.com\/nginx-gzip_static\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.carnaghan.com\/nginx-gzip_static\/\",\"url\":\"https:\/\/www.carnaghan.com\/nginx-gzip_static\/\",\"name\":\"Nginx gzip_static: What it does and how to use it? - Ian Carnaghan\",\"isPartOf\":{\"@id\":\"https:\/\/www.carnaghan.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.carnaghan.com\/nginx-gzip_static\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.carnaghan.com\/nginx-gzip_static\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/www.carnaghan.com\/wp-content\/uploads\/2017\/12\/NGINX-logo.jpg\",\"datePublished\":\"2017-12-18T17:28:12+00:00\",\"dateModified\":\"2020-05-31T01:31:28+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.carnaghan.com\/nginx-gzip_static\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.carnaghan.com\/nginx-gzip_static\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.carnaghan.com\/nginx-gzip_static\/#primaryimage\",\"url\":\"http:\/\/www.carnaghan.com\/wp-content\/uploads\/2017\/12\/NGINX-logo.jpg\",\"contentUrl\":\"http:\/\/www.carnaghan.com\/wp-content\/uploads\/2017\/12\/NGINX-logo.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.carnaghan.com\/nginx-gzip_static\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.carnaghan.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Nginx gzip_static: What it does and how to use it?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.carnaghan.com\/#website\",\"url\":\"https:\/\/www.carnaghan.com\/\",\"name\":\"Ian Carnaghan\",\"description\":\"Software Developer, Blogger, Educator\",\"publisher\":{\"@id\":\"https:\/\/www.carnaghan.com\/#\/schema\/person\/c689c24d516c51968a88b628860740a5\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.carnaghan.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.carnaghan.com\/#\/schema\/person\/c689c24d516c51968a88b628860740a5\",\"name\":\"Ian Carnaghan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.carnaghan.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f2aa5baca80c2be728de43a975185d91?s=96&d=retro&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f2aa5baca80c2be728de43a975185d91?s=96&d=retro&r=g\",\"caption\":\"Ian Carnaghan\"},\"logo\":{\"@id\":\"https:\/\/www.carnaghan.com\/#\/schema\/person\/image\/\"},\"description\":\"I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment.\",\"sameAs\":[\"http:\/\/www.carnaghan.com\",\"https:\/\/twitter.com\/icarnaghan\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.carnaghan.com\/#\/schema\/person\/f52a97a0d4f7b309922ab0381d337bbb\",\"name\":\"Pramod\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.carnaghan.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/9b9cc255f2495f5394b801428d7d6929?s=96&d=retro&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/9b9cc255f2495f5394b801428d7d6929?s=96&d=retro&r=g\",\"caption\":\"Pramod\"},\"description\":\"My name is Pramod. I\u2019m a software developer (with good knowledge on PHP, JAVA \u2013 Android, JavaScript, CSS), blogger and online marketing professional. I\u2019ve 3 years of experience as a blogger and 2 years of full time experience as a software developer.\",\"url\":\"https:\/\/www.carnaghan.com\/author\/prhost78\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Nginx gzip_static: What it does and how to use it? - Ian Carnaghan","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.carnaghan.com\/nginx-gzip_static\/","og_locale":"en_US","og_type":"article","og_title":"Nginx gzip_static: What it does and how to use it? - Ian Carnaghan","og_description":"Like other top\u00a0web servers, Nginx lets webmasters enable Gzip compression for their websites. It can compress scripts and stylesheets in a web page on the fly. The Gzip file’s size is significantly lower than the original file.\u00a0Nginx supports 9 Gzip compression levels.1 is the lowest and 9 is the highest. To gzip a file, Nginx […]","og_url":"https:\/\/www.carnaghan.com\/nginx-gzip_static\/","og_site_name":"Ian Carnaghan","article_published_time":"2017-12-18T17:28:12+00:00","article_modified_time":"2020-05-31T01:31:28+00:00","og_image":[{"url":"http:\/\/www.carnaghan.com\/wp-content\/uploads\/2017\/12\/NGINX-logo.jpg"}],"author":"Pramod","twitter_card":"summary_large_image","twitter_creator":"@icarnaghan","twitter_site":"@icarnaghan","twitter_misc":{"Written by":"Pramod","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.carnaghan.com\/nginx-gzip_static\/#article","isPartOf":{"@id":"https:\/\/www.carnaghan.com\/nginx-gzip_static\/"},"author":{"name":"Pramod","@id":"https:\/\/www.carnaghan.com\/#\/schema\/person\/f52a97a0d4f7b309922ab0381d337bbb"},"headline":"Nginx gzip_static: What it does and how to use it?","datePublished":"2017-12-18T17:28:12+00:00","dateModified":"2020-05-31T01:31:28+00:00","mainEntityOfPage":{"@id":"https:\/\/www.carnaghan.com\/nginx-gzip_static\/"},"wordCount":443,"commentCount":1,"publisher":{"@id":"https:\/\/www.carnaghan.com\/#\/schema\/person\/c689c24d516c51968a88b628860740a5"},"image":{"@id":"https:\/\/www.carnaghan.com\/nginx-gzip_static\/#primaryimage"},"thumbnailUrl":"http:\/\/www.carnaghan.com\/wp-content\/uploads\/2017\/12\/NGINX-logo.jpg","keywords":["Affiliate","Nginx"],"articleSection":["Coding"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.carnaghan.com\/nginx-gzip_static\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.carnaghan.com\/nginx-gzip_static\/","url":"https:\/\/www.carnaghan.com\/nginx-gzip_static\/","name":"Nginx gzip_static: What it does and how to use it? - Ian Carnaghan","isPartOf":{"@id":"https:\/\/www.carnaghan.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.carnaghan.com\/nginx-gzip_static\/#primaryimage"},"image":{"@id":"https:\/\/www.carnaghan.com\/nginx-gzip_static\/#primaryimage"},"thumbnailUrl":"http:\/\/www.carnaghan.com\/wp-content\/uploads\/2017\/12\/NGINX-logo.jpg","datePublished":"2017-12-18T17:28:12+00:00","dateModified":"2020-05-31T01:31:28+00:00","breadcrumb":{"@id":"https:\/\/www.carnaghan.com\/nginx-gzip_static\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.carnaghan.com\/nginx-gzip_static\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.carnaghan.com\/nginx-gzip_static\/#primaryimage","url":"http:\/\/www.carnaghan.com\/wp-content\/uploads\/2017\/12\/NGINX-logo.jpg","contentUrl":"http:\/\/www.carnaghan.com\/wp-content\/uploads\/2017\/12\/NGINX-logo.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.carnaghan.com\/nginx-gzip_static\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.carnaghan.com\/"},{"@type":"ListItem","position":2,"name":"Nginx gzip_static: What it does and how to use it?"}]},{"@type":"WebSite","@id":"https:\/\/www.carnaghan.com\/#website","url":"https:\/\/www.carnaghan.com\/","name":"Ian Carnaghan","description":"Software Developer, Blogger, Educator","publisher":{"@id":"https:\/\/www.carnaghan.com\/#\/schema\/person\/c689c24d516c51968a88b628860740a5"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.carnaghan.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.carnaghan.com\/#\/schema\/person\/c689c24d516c51968a88b628860740a5","name":"Ian Carnaghan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.carnaghan.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/f2aa5baca80c2be728de43a975185d91?s=96&d=retro&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f2aa5baca80c2be728de43a975185d91?s=96&d=retro&r=g","caption":"Ian Carnaghan"},"logo":{"@id":"https:\/\/www.carnaghan.com\/#\/schema\/person\/image\/"},"description":"I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment.","sameAs":["http:\/\/www.carnaghan.com","https:\/\/twitter.com\/icarnaghan"]},{"@type":"Person","@id":"https:\/\/www.carnaghan.com\/#\/schema\/person\/f52a97a0d4f7b309922ab0381d337bbb","name":"Pramod","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.carnaghan.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/9b9cc255f2495f5394b801428d7d6929?s=96&d=retro&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9b9cc255f2495f5394b801428d7d6929?s=96&d=retro&r=g","caption":"Pramod"},"description":"My name is Pramod. I\u2019m a software developer (with good knowledge on PHP, JAVA \u2013 Android, JavaScript, CSS), blogger and online marketing professional. I\u2019ve 3 years of experience as a blogger and 2 years of full time experience as a software developer.","url":"https:\/\/www.carnaghan.com\/author\/prhost78\/"}]}},"views":6308,"_links":{"self":[{"href":"https:\/\/www.carnaghan.com\/wp-json\/wp\/v2\/posts\/7158"}],"collection":[{"href":"https:\/\/www.carnaghan.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.carnaghan.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.carnaghan.com\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.carnaghan.com\/wp-json\/wp\/v2\/comments?post=7158"}],"version-history":[{"count":0,"href":"https:\/\/www.carnaghan.com\/wp-json\/wp\/v2\/posts\/7158\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.carnaghan.com\/wp-json\/wp\/v2\/media?parent=7158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.carnaghan.com\/wp-json\/wp\/v2\/categories?post=7158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.carnaghan.com\/wp-json\/wp\/v2\/tags?post=7158"},{"taxonomy":"post_series","embeddable":true,"href":"https:\/\/www.carnaghan.com\/wp-json\/wp\/v2\/post_series?post=7158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}