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

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.

相关推荐