# Stylesheet\_link\_tag, javascript\_include\_tag, caching problems

**URL:** <https://www.ruby-forum.com/t/stylesheet-link-tag-javascript-include-tag-caching-problems/139325>\
**Category:** Rails\
**Created:** [June 2, 2008, 10:57pm UTC](https://www.ruby-forum.com/t/stylesheet-link-tag-javascript-include-tag-caching-problems/139325 "2008-06-02T22:57:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Choi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b487fb/32.png) [@Alex\_Choi](https://www.ruby-forum.com/u/Alex_Choi)\
**Post date:** [June 2, 2008, 10:57pm UTC](https://www.ruby-forum.com/t/stylesheet-link-tag-javascript-include-tag-caching-problems/139325/1 "2008-06-02T22:57:53Z")

</div>

So, the new caching for stylesheet\_link\_tag, javascript\_include\_tag  
which rolls up the files into one all.js or all.css files is great …  
however I’ve run into an issue:

If all.cs or all.js don’t exist, they get generated … great, I’ve  
reduced the number of gets …

The problem is what occurs when the files already exist … even if  
I’ve changed my list of js/css files to something completely  
different, it won’t rewrite the file if it already exists …

Do we really need the unless in this block? (asset\_tag\_helper.rb)

```
    def write_asset_file_contents(joined_asset_path, asset_paths)
      unless file_exist?(joined_asset_path)
        FileUtils.mkdir_p(File.dirname(joined_asset_path))
        File.open(joined_asset_path, "w+") { |cache|

```

cache.write(join\_asset\_file\_contents(asset\_paths)) }  
end  
end
