speed up file/image performance

this eliminates a LOT of unnecessary db queries
basically injects a variable into the cache