Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Use file contents as hash seed for cache #99

Closed
wants to merge 1 commit into from

4 participants

@jcartledge

Hi. Thanks for wordless, I love it.

I had trouble deploying my site to heroku because the filemtime gets set on all the files during deployment which breaks the asset caching. The obvious fix for this is to generate the cache hash from the asset file contents instead of filepath + filemtime, and it seems like that's how this used to work (see f136277#commitcomment-1011805)

Is there a reason why this is a bad idea?

(Possible related issue: #39)

@etienne

I haven't tested it, but in principle I agree with this change. Maybe someone can chime in about why Wordless moved away from this solution in the first place?

@talbet

I have also run into trouble pushing a site to a VPN running PHP but not ruby and having wordless try to recompile. Time stamps are the same between local and server but file paths are different.

Can anyone suggest a way to stop recompiling on a new server? Am also interested in why the move from file hash to file path/timestamp was made.

Using jcartledge's fork for now, which works great.

@stefanoverna

Sorry for the delay :)

The move was due to the fact that it can be quite slow (and useless) to read all the assets just to generate a hash. Think about a Sass stylesheet with 50 imports, each with a hundred lines.

In production, you shouldn't rely on assets caching to avoid assets compilation: you need to bake/compile them in the public folder, using the awesome gem @etienne created https://github.com/etienne/wordless_gem

What do you think about it?

@jcartledge

That sounds like it would work - somehow I missed mention of this workflow in the docs. I'll give it a try. Thanks.

@stefanoverna
@STRML STRML referenced this pull request from a commit in STRML/wordless
@STRML STRML Fix for issue #98 and #107. Includes fix for #99. 4b67bb5
@stefanoverna

Closing this for now :) Thanks everyone for the feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 15, 2012
  1. @jcartledge
This page is out of date. Refresh to see the latest.
View
2  wordless/preprocessors/compass_preprocessor.php
@@ -42,7 +42,7 @@ protected function asset_hash($file_path) {
sort($files);
$hash_seed = array();
foreach ($files as $file) {
- $hash_seed[] = $file . date("%U", filemtime($file));
+ $hash_seed[] = file_get_contents($file);
}
return md5(join($hash_seed));
}
View
2  wordless/preprocessors/less_preprocessor.php
@@ -37,7 +37,7 @@ protected function asset_hash($file_path) {
sort($files);
$hash_seed = array();
foreach ($files as $file) {
- $hash_seed[] = $file . date("%U", filemtime($file));
+ $hash_seed[] = file_get_contents($file);
}
return md5(join($hash_seed));
}
View
2  wordless/preprocessors/sprockets_preprocessor.php
@@ -38,7 +38,7 @@ protected function asset_hash($file_path) {
sort($files);
$hash_seed = array();
foreach ($files as $file) {
- $hash_seed[] = $file . date("%U", filemtime($file));
+ $hash_seed[] = file_get_contents($file);
}
return md5(join($hash_seed));
}
View
2  wordless/preprocessors/wordless_preprocessor.php
@@ -93,7 +93,7 @@ protected function comment_line($line) {
*/
protected function asset_hash($file_path) {
// First we get the file content
- $hash_seed = date("%U", filemtime($file_path));
+ $hash_seed = file_get_contents($file_path);
// Then we attach the preferences
foreach ($this->preferences_defaults as $pref => $value) {
Something went wrong with that request. Please try again.