I've been having real problems with browser cache clearing in a fusion subtheme.

Changes that I make in the subtheme local.css just aren't being picked up by Firefox or IE.

Drupal cache clear, browser cache clear, reboot, not behind proxy cache, multiple locations and all that jazz... just not picking up.

Anyway, I note that something may help this.

In @common.inc @drupal_get_css caching issues are somewhat mitigated by adding a query string to the end of each css file name like so:

$query_string = '?'. substr(variable_get('css_js_query_string', '0'), 0, 1);

That is not being done for fusion in @template.php in @fusion_core_preprocess_page(&$vars).

My suggestion is that you might consider adding a string just like core does.

So... at ~ line 98 in template.php

  // Get query string like core
  $query_string = '?'. substr(variable_get('css_js_query_string', '0'), 0, 1);
  foreach ($themes as $name => $path) {
    $link = '<link type="text/css" rel="stylesheet" media="all" href="' . base_path() . $path;
    $vars['setting_styles'] .= (file_exists($path . $grid_style . '.css')) ? $link . $grid_style . '.css' . $query_string . '" />' . "\n" : '';
    $vars['ie6_styles'] .= (file_exists($path . '/css/ie6-fixes.css')) ? $link . '/css/ie6-fixes.css' . $query_string . '" />' . "\n" : '';
    $vars['ie7_styles'] .= (file_exists($path . '/css/ie7-fixes.css')) ? $link . '/css/ie7-fixes.css' . $query_string . '" />' . "\n" : '';
    $vars['ie8_styles'] .= (file_exists($path . '/css/ie8-fixes.css')) ? $link . '/css/ie8-fixes.css' . $query_string . '" />' . "\n" : '';
    $vars['local_styles'] .= (file_exists($path . '/css/local.css')) ? $link . '/css/local.css' . $query_string . '" />' . "\n" : '';
    if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) {
      $vars['setting_styles'] .= (file_exists($path . $grid_style . '-rtl.css')) ? $link . $grid_style . '-rtl.css' . $query_string . '" />' . "\n" : '';
      $vars['ie6_styles'] .= (file_exists($path . '/css/ie6-fixes-rtl.css')) ? $link . '/css/ie6-fixes-rtl.css' . $query_string . '" />' . "\n" : '';
      $vars['ie7_styles'] .= (file_exists($path . '/css/ie7-fixes-rtl.css')) ? $link . '/css/ie7-fixes-rtl.css' . $query_string . '" />' . "\n" : '';
      $vars['ie8_styles'] .= (file_exists($path . '/css/ie8-fixes-rtl.css')) ? $link . '/css/ie8-fixes-rtl.css' . $query_string . '" />' . "\n" : '';
      $vars['local_styles'] .= (file_exists($path . '/css/local-rtl.css')) ? $link . '/css/local-rtl.css' . $query_string . '" />' . "\n" : '';
    }
  }

Comments

sethviebrock’s picture

Same issue. Sometimes a CSS edit will not show up for a minute or so, even after clearing all Drupal caches, with the theme registry being rebuilt on each page load, no CSS aggregation, no caching, nothing. I tried putting the above solution in my subtheme's preprocess_page function to no avail.

hongpong’s picture

subscribe

ezra-g’s picture

Status: Active » Needs review
StatusFileSize
new3.12 KB

While I wasn't able to reproduce the symptom in Firefox 3.6.15 on OS X 10.6.6, the solution proposed here sounds reasonable, since it follows the behavior of Drupal core.

When *not* aggregating, change the query string on each css file when the cache is cleared.

Since these stylesheets specifically avoid aggregation, we add the query string to them following the approach used in common.inc.

Here it is as a patch for review.

coltrane’s picture

StatusFileSize
new3.66 KB

grids.css was missing the query string. I also couldn't replicate but think the method is sound. @willieseabrook, @sviebrock or @HongPong can you test this?

giorgosk’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new3.64 KB

it works as expected

I only had to erase
the last 3 lines from the last patch

---
1.7.2 

as my netbeans IDE would not apply the patch ???
otherwise its the same patch as above

aquariumtap’s picture

Status: Reviewed & tested by the community » Closed (fixed)

looks good. patch committed!

js’s picture

This is really great. Thanks. I can stop counts restarts of varnish as well as other attempts to flush the various cache.

bkosborne’s picture

Glad to have this in here as well!