I started with 5 normal human-readable JavaScript files - they were around 10 KB in total.
After using YSlow, I decided to merge the 5 files and pack them using Dean Edwards' packer. Now I have 1 file that is 4.5 KB.
When I re-run YSlow, it is now showing the JavaScript file开发者_开发百科 in the primed cache under 'statistics', where previously (when I had the separate files) the 5 files would have been cached.
So I now have 4 fewer HTTP requests but the total page weight for the primed cache is up by 4.5 KB.
Am I doing something wrong?
I am still planning to put a far-forward expiry date header on my JavaScript folder so this issue will likely disappear, but I'm still interested to know why it won't cache the JavaScript files.
I don't think you are doing anything wrong at all, you are following all basic best practices.
When you download something from a webserver that doesn't have expires
set properly, which I assume is the case since you want to fix that, the primed cache will always be higher because YSlow thinks that the browser needs to download it even when it has cached everything.
This is because the cache is set to expire when its downloaded it because there is not Expires header. Updating your expires to have a long living expires will definitely sort your issue out.
精彩评论