Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The first question you should ask yourself is, is there any point in doing this? Do you notice too high cpu load and/or performance difference because of this? My guess would be that you are probably not running into this problem :)</p> <p>Regardless though, there are multiple ways of fixing your problem.</p> <ol> <li><p>Probably the best option for you, use a CDN. They are designed for fast delivery of static files and will make it fast for people in a different geographical area as well as people close to your server. Also, in my experience CDN's are usually much cheaper than your own bandwidth will be.</p></li> <li><p>Use Nginx. For hosting static files <strong>much</strong> faster and has support for pre generating static content like you are doing right now. It will automatically detect if there's a <code>.gz</code> file and serve that instead when needed.</p></li> <li><p>Use one of the Apache cache mechanisms like <code>mod_mem_cache</code> or <code>mod_disk_cache</code> to make sure that every regularly used file will be in cache. Tutorial: <a href="http://webdirect.no/linux/apache-caching-with-gzip-enabled/" rel="noreferrer">http://webdirect.no/linux/apache-caching-with-gzip-enabled/</a></p></li> <li><p>Use a caching proxy like Varnish in front of it, these type of servers have a much smarter caching mechanism and will actually cache the files that matter most.</p></li> </ol> <p>For your current version however, something like this (untested) should do the trick:</p> <pre><code>RewriteEngine On RewriteCond %{HTTP:Accept-encoding} gzip RewriteCond %{REQUEST_FILENAME}\.gz -s RewriteRule ^(.*)\.(html|css|js|data) $1\.$2\.gz [QSA] # Prevent double gzip and give the correct mime-type RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1,E=FORCE_GZIP] RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1,E=FORCE_GZIP] RewriteRule \.html\.gz$ - [T=text/html,E=no-gzip:1,E=FORCE_GZIP] RewriteRule \.data\.gz$ - [T=text/plain,E=no-gzip:1,E=FORCE_GZIP] Header set Content-Encoding gzip env=FORCE_GZIP </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload