how the drupal set css/js query string for cache buster

张大晴 2012-12-13

Css/js can be cached by browser, CDN or Varnish cache. If a new version css/js released, we want browser/CDN/Varnish request drupal to get new version.

Drupalwillappendarandomstringtocss/jssurltoworkascachebuster.

[Howtogeneratequerystring?]

ThisrandomstringisstoredinDBvariabletablebydefault,namedas‘css_js_query_string’.Whencommon.incdrupal_flush_all_caches()iscalled,itwillcall_drupal_flush_css_js()thengeneratearandomstringwith6characters.

Wecanalsohardcodethevalueinsettings.php.

[Howtousethequerystring?]

Incommon.incdrupal_pre_render_styles()function,itwillcallvariable_get(‘css_js_query_string’,0)togetthevalueandappendoneachcss.

相关推荐

会写code的凳子哥 / 0评论 2011-07-19