Title: Gzip, Expire Headers, Inline CSS/JS
Last modified: May 6, 2019

---

# Gzip, Expire Headers, Inline CSS/JS

 *  Resolved [heutger](https://wordpress.org/support/users/heutger/)
 * (@heutger)
 * [7 years ago](https://wordpress.org/support/topic/gzip-expire-headers-inline-css-js/)
 * Hi,
 * I’m unsure on how to get Gzip running. Your FAQ is a bit short to just enable
   an option as I don’t know how to. After googling a bit around, I found, it should
   be done with functions.php or additional plugin Code Snippets and adding there
   add_filter(‘autoptimize_filter_cache_create_static_gzip’,’__return_true’); and
   after doing that I recognized (maybe also had been done before) .gz files have
   been created, but I did not saw them been used? Scripts and Styles are still 
   loading the non-gz files? Any additional changes needed (used Super Cache to 
   test it).
 * Also I got errors by changing W3TC to Super Cache and Autoptimize and worser 
   scores as Expire Headers aren’t set for images as well as for the Autoptimize
   CSS and JS. Doesn’t Autoptimize offer such an option?
 * I tried around because I want to remove Emoji-Code as well as Google Fonts (or
   integrate them by caching them local) but primary because of CSP issues with 
   inline JS and inline CSS and hoped activating aggregate would move them all out
   to external files, but either after activating I need to purge any additional
   caches or inline JS and inline CSS isn’t moved to external files? Also I tried
   to integrate jscript.js, you state that popular plugins use jscript.js, but which
   ones are using jscript.js? There was no list of such ones.
 * Regards,
    Christian

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [7 years ago](https://wordpress.org/support/topic/gzip-expire-headers-inline-css-js/#post-11500205)
 * OK, so `add_filter(‘autoptimize_filter_cache_create_static_gzip’,’__return_true’);`
   is there to create static gzip files, how those are to be served by the webserver
   is up to the webserver config and is different between webserver version (Apache,
   IIS, nginx, …).
 * Normally you just want the webserver to do the gzipping “on the fly”. for this
   purpose AO adds a .htaccess file which gently asks Apache (but not other webservers)
   to do the gzipping and set expiry for the autoptimized files, but Apache (depending
   on config and higher up .htaccess files) can still choose not to honor AO’s .
   htaccess. In most cases deactivating the “serve as static files”-option fixes
   this (but there’s a known issue with WP Super Cache’s .htaccess which sets expiry
   to 3, if you have that you might want to change that).
 * AO by default moves inline CSS to the autoptimized CSS-file, but does _not_ do
   so for inline JS as that risks causing a big number of files in the Autoptimize
   cache (and [more important but less visible issues](https://blog.futtta.be/2016/09/15/autoptimize-cache-size-the-canary-in-the-coal-mine/)).
   Even if “also aggregate inline JS” is on, some of it will be excluded anyhow (
   e.g. JS containing nonce’s or document.write or google ads JS or …).
 * Lastly; not sure what you are referring to with `jscript.js` I’m afraid, can 
   you clarify?
 * frank
 *  Thread Starter [heutger](https://wordpress.org/support/users/heutger/)
 * (@heutger)
 * [7 years ago](https://wordpress.org/support/topic/gzip-expire-headers-inline-css-js/#post-11500497)
 * Hi,
 * ok, then I need to try with non-static option as I have Apache and over code 
   is served as gzip. Do you recommend any additional cache plugin as W3TC seems
   to have issues as well as Super Cache?
 * Also by optimizing my inline code to outsourced code I tried your aggregate function,
   by default with CSS but also then by activating JS GTMetrix still stated to me,
   that there is inline CSS and inline JS left? So for JS you stated, it can be,
   but for CSS I thought it will work?
 * jscript.js is per default excluded on your side, so I tried to remove exclusion
   and worked well. However, in your FAQ here on the plugin page (first page of 
   your plugin description) you write in your FAQ why to exclude jscript.js as “
   popular plugins” will get use of and will then get in trouble, but you don’t 
   state anywhere, which plugins there are.
 * Regards,
    Christian
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [7 years ago](https://wordpress.org/support/topic/gzip-expire-headers-inline-css-js/#post-11500583)
 * I use WP Super Cache myself, have encountered no issues except for the short 
   expiry mishap in their .htaccess. Alternative could be KeyCDN Cache enabler maybe?
 * > So for JS you stated, it can be, but for CSS I thought it will work?
 * No idea, but if you can share your URL I can have a quick look.
 * > jscript.js is per default excluded on your side, so I tried to remove exclusion
   > and worked well. However, in your FAQ here on the plugin page (first page of
   > your plugin description) you write in your FAQ why to exclude jscript.js as“
   > popular plugins” will get use of and will then get in trouble, but you don’t
   > state anywhere, which plugins there are.
 * ah, jquery.js. well, don’t have a list of those, but if you removed jquery.js
   from the exclusion list, tested and all works well, then you can safely leave
   it be 🙂
 *  Thread Starter [heutger](https://wordpress.org/support/users/heutger/)
 * (@heutger)
 * [7 years ago](https://wordpress.org/support/topic/gzip-expire-headers-inline-css-js/#post-11500625)
 * Is this expiry mishap what I also mentioned for the images? So is it a bug, which
   should be filed for their plugin?
 * [http://www.heutger.net](http://www.heutger.net) is the URL, however, I switched
   back to W3TC currently.
 * Ok, looked like you had played around a bit with some plugins and have an experience
   list, for sure, you won’t be able to provide a full list of all plugins which
   may arise problems. 😉
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [7 years ago](https://wordpress.org/support/topic/gzip-expire-headers-inline-css-js/#post-11500671)
 * > Is this expiry mishap what I also mentioned for the images?
 * don’t think so, but not 100% sure
 * > Ok, looked like you had played around a bit with some plugins and have an experience
   > list,
 * don’t have lists, plugins can change overnight so a list would require updating
   which would require testing which would require time which … I don’t have 😉

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Gzip, Expire Headers, Inline CSS/JS’ is closed to new replies.

 * ![](https://ps.w.org/autoptimize/assets/icon-256X256.png?rev=2211608)
 * [Autoptimize](https://wordpress.org/plugins/autoptimize/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/autoptimize/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/autoptimize/)
 * [Active Topics](https://wordpress.org/support/plugin/autoptimize/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/autoptimize/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/autoptimize/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * Last activity: [7 years ago](https://wordpress.org/support/topic/gzip-expire-headers-inline-css-js/#post-11500671)
 * Status: resolved