css_emimage will sometimes output different filenames that have the same content. Need a way to verify the cached result. Run on cron and modify the cache to not load un-needed files.

CommentFileSizeAuthor
#3 advagg-1181928-3.patch6.17 KBmikeytown2

Comments

mikeytown2’s picture

String to look for in the file is "html {display:block;}". If it contains that, remove it from the bundled cache object in advagg_css_js_file_builder $cached_data_key = 'advagg_file_builder_' . md5(implode('', array_filter(array_unique($files))));

mikeytown2’s picture

This finds all empty files from the DB. Still need to account for modifiers like css_emimage.

function advagg_remove_empty_files() {
  // Get the filetype paths.
  list($css_path, $js_path) = advagg_get_root_files_dir();

  // Get a list of all bundles from the DB.
  $results = db_query("
    SELECT
      af.filetype,
      ab.bundle_md5,
      ab.counter
    FROM advagg_bundles AS ab
    INNER JOIN advagg_files AS af USING (filename_md5)
    GROUP BY bundle_md5
  ");

  $files = array();
  while ($row = db_fetch_array($results)) {
    $row['filename'] = advagg_build_filename($row['filetype'], $row['bundle_md5'], $row['counter']);
    if ($row['filetype'] == 'css') {
      $row['filepath'] = $css_path . '/' . $row['filename'];
    }
    if ($row['filetype'] == 'js') {
      $row['filepath'] = $js_path . '/' . $row['filename'];
    }
    $files[] = $row;
  }

  // Find the empty files.
  $empty_list = array();
  foreach ($files as $fileinfo) {
    // Skip if the file is not readable.
    if (!file_exists($fileinfo['filepath']) || !is_readable($fileinfo['filepath'])) {
      continue;
    }

    $contents = trim(file_get_contents($fileinfo['filepath']));
    if (empty($contents) || $contents == 'html {display:block;}') {
      $empty_list[] = $fileinfo;
    }
  }

  // Return if there are no empty files.
  if (empty($empty_list)) {
    return;
  }

}
mikeytown2’s picture

Status: Active » Needs work
StatusFileSize
new6.17 KB

patch of what I have so far. Still needs work.

killes@www.drop.org’s picture

Is there something that I can do to help this along? I am getting a couple of small "html block" css files and would rather not.

mikeytown2’s picture

Issue summary: View changes
Status: Needs work » Closed (won't fix)

Marking this a won't fix. Someone can take the patch I had and continue on if desired.