One of 2 options.

1. Create a "permanent" folder just like the "gz" folder and store all css/js files in there. If doing this, also create a "normal" folder as well.

2. Rewrite _boost_rmdir_rf() so it only targets html, xml and ajax(js) files. Could be a little tricky.

Thoughts?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikeytown2’s picture

Title: Prevent css/js files from ever being deleted on a flush. » Next round of .htaccess changes. Getting these "perfect" is the goal.
Status: Active » Needs review

Incorporating this &
#489824: IE tries to download a file instead of opening a page with gzip
#528506: Better Detect GZIP Compression
Use .ajax instead of .js for json/ajax responses.
http://drupal.org/node/545922#comment-1911702

One final note is the charset is not getting set if serving .gz files. AddCharset utf-8 .gz doesn't work in case your wondering. Any ideas on this minor issue?

  ### BOOST START ###
  <FilesMatch "(\.html\.gz|\.html|\.xml\.gz|\.xml|\.ajax\.gz|\.ajax)$">
    <IfModule mod_headers.c>
      Header set Expires "Sun, 19 Nov 1978 05:00:00 GMT"
      Header set Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"
    </IfModule>
  </FilesMatch>
  <IfModule mod_mime.c>
    AddCharset utf-8 .html
    AddCharset utf-8 .xml
    AddCharset utf-8 .js
    AddCharset utf-8 .ajax
    AddCharset utf-8 .css
    AddEncoding gzip .gz
  </IfModule>
  <FilesMatch "\.html\.gz$">
    ForceType text/html
  </FilesMatch>
  <FilesMatch "\.xml\.gz$">
    ForceType text/xml
  </FilesMatch>
  <FilesMatch "\.css\.gz$">
    ForceType text/css
  </FilesMatch>
  <FilesMatch "\.js\.gz$">
    ForceType text/javascript
  </FilesMatch>
  <FilesMatch "\.ajax\.gz$">
    ForceType text/javascript
  </FilesMatch>
  
  # Gzip Cookie Test
  RewriteRule boost-gzip-cookie-test\.html cache/permanent/boost-gzip-cookie-test\.html\.gz [L,T=text/html]

  # GZIP - Cached css & js files
  RewriteCond %{HTTP_COOKIE} !(boost-gzip) [OR]
  RewriteCond %{HTTP:Accept-encoding} !gzip
  RewriteRule .* - [S=2]
  RewriteCond %{DOCUMENT_ROOT}/cache/permanent/%{SERVER_NAME}%{REQUEST_URI}_\.css\.gz -s
  RewriteRule .* cache/permanent/%{SERVER_NAME}%{REQUEST_URI}_\.css\.gz [L,QSA,T=text/css]
  RewriteCond %{DOCUMENT_ROOT}/cache/permanent/%{SERVER_NAME}%{REQUEST_URI}_\.js\.gz -s
  RewriteRule .* cache/permanent/%{SERVER_NAME}%{REQUEST_URI}_\.js\.gz [L,QSA,T=text/javascript]

  # NORMAL - Cached css & js files
  RewriteCond %{DOCUMENT_ROOT}/cache/permanent%{SERVER_NAME}%{REQUEST_URI}_\.css -s
  RewriteRule .* cache/permanent%{SERVER_NAME}%{REQUEST_URI}_\.css [L,QSA,T=text/css]
  RewriteCond %{DOCUMENT_ROOT}/cache/permanent%{SERVER_NAME}%{REQUEST_URI}_\.js -s
  RewriteRule .* cache/permanent%{SERVER_NAME}%{REQUEST_URI}_\.js [L,QSA,T=text/javascript]

  # Caching for anonymous users
  # Skip boost IF not get request OR uri has wrong dir OR cookie is set OR https request
  RewriteCond %{REQUEST_METHOD} !^GET$ [OR]
  RewriteCond %{REQUEST_URI} (^/july(admin|cache|misc|modules|sites|system|themes|node/add))|(/(comment/reply|edit|user|user/(login|password|register))$) [OR]
  RewriteCond %{HTTP_COOKIE} DRUPAL_UID [OR]
  RewriteCond %{HTTPS} on
  RewriteRule .* - [S=7]

  # GZIP
  RewriteCond %{HTTP_COOKIE} !(boost-gzip) [OR]
  RewriteCond %{HTTP:Accept-encoding} !gzip
  RewriteRule .* - [S=3]
  RewriteCond %{DOCUMENT_ROOT}/cache/gzip/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.html\.gz -s
  RewriteRule .* cache/gzip/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.html\.gz [L,T=text/html]
  RewriteCond %{DOCUMENT_ROOT}/cache/gzip/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.xml\.gz -s
  RewriteRule .* cache/gzip/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.xml\.gz [L,T=text/xml]
  RewriteCond %{DOCUMENT_ROOT}/cache/gzip/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.ajax\.gz -s
  RewriteRule .* cache/gzip/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.ajax\.gz [L,T=text/javascript]

  # NORMAL
  RewriteCond %{DOCUMENT_ROOT}/cache/normal/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.html -s
  RewriteRule .* cache/normal/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html]
  RewriteCond %{DOCUMENT_ROOT}/cache/normal/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.xml -s
  RewriteRule .* cache/normal/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.xml [L,T=text/xml]
  RewriteCond %{DOCUMENT_ROOT}/cache/normal/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.ajax -s
  RewriteRule .* cache/normal/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.ajax [L,T=text/javascript]

  ### BOOST END ###
mikeytown2’s picture

Make the various subdir's be changable via text field; allowing for "backwards compatibility". So for normal you would leave it blank, and for gzip set it to gz/. Checkbox for the permanent dir since that combines normal and gzip to have it work the old way. Allow one to pick each extension for each filetype. The gzip cookie test would be enabled via a checkbox; only on non-gzipped page; check for cookie, if not then do iframe test.

mikeytown2’s picture

Make generation & requirements be built based on the settings; minimalist approach for htaccess file additions, only use what you need.

mikeytown2’s picture

Status: Needs review » Needs work
FileSize
6.83 KB

1/2 there

mikeytown2’s picture

Status: Needs work » Needs review
FileSize
13.96 KB

This should be 100% compatible with the current setup... now I need to work on an upgrade or something.

mikeytown2’s picture

Status: Needs review » Active

committed, need to work on some sort of update function... probably going to use glob, would be nice if this could be an optional one.

mikeytown2’s picture

Status: Active » Needs work

Also need to add in the gzip cookie test; inject it on the front page only, only on the non gzip one. Make it an option

mikeytown2’s picture

Status: Needs work » Needs review
FileSize
7.47 KB

cookie test integrated

mikeytown2’s picture

Status: Needs review » Fixed

committed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.