Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
css last modified
#1
I was thinking about submitting this to GitHub.

Any thoughts on the following change? It would allow for effective caching of css.

global.php (around line 356)

replace
$theme_stylesheets[basename($page_stylesheet)] = "<link type=\"text/css\" rel=\"stylesheet\" href=\"{$stylesheet_url}\" />\n";

with
$lastmod = filemtime($page_stylesheet);
$theme_stylesheets[basename($page_stylesheet)] = "<link type=\"text/css\" rel=\"stylesheet\" href=\"{$stylesheet_url}?lastmod={$lastmod}\" />\n";
Reply
#2
A great thought!

Adding a query string ({$stylesheet_url}?lastmod) to the CSS file would cause an immediate refresh of changes in the stylesheet (without forcing the browser to refresh manually). That's the behaviour of most common browsers.

A single build version/counter ({$stylesheet_url}?build) would comply to take effect instead of ?lastmod=value.

[ExiTuS]
Reply
#3
File hash could also work, but it might be longer.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)