Static Asset Compilation
21–30 of 41 posts
Re: Static Asset Compilation
#22You don't need to rename the files. As of a few months ago, you can configure CloudFront to take query strings into account when caching, so you can simply link to the file as normal but append "? " to the filename. (I actually prefer using the last modified timestamp over a hash.) IMHO, this is better because it requires less magic on the origin server. And even ancient references to a file (a logo someone hotlinked…
https://developers.google.com/speed/docs/best-practices/cach...
Re: Static Asset Compilation
#23You don't need to rename the files. As of a few months ago, you can configure CloudFront to take query strings into account when caching, so you can simply link to the file as normal but append "? " to the filename. (I actually prefer using the last modified timestamp over a hash.) IMHO, this is better because it requires less magic on the origin server. And even ancient references to a file (a logo someone hotlinked…
This isn't recommended since many browsers and proxies do not cache resources that are referenced using a query string, even if a cache-control or expires header is set appropriately. Google says Squid up to 3.0 will not do so: https://developers.google.com/speed/docs/best-practices/cach...
Re: Static Asset Compilation
#24I would have thought that most web frameworks do all these things for you automatically by now.
Re: Static Asset Compilation
#25Is putting hash digests in filenames really easier than sending Last-Modified headers in the response, parsing If- Modified-Since headers and returning 304 when applicable, and/or using ETags? I would have thought that most web frameworks do all these things for you automatically by now.
Re: Static Asset Compilation
#26Fairly standard stuff. If you're going to have a title with "you're doing it wrong" you should have some unique insight to support your dramatised title.
Re: Static Asset Compilation
#27Re: Static Asset Compilation
#28Is ImageOptim still a good choice to go with? I really like the simplicity of the GUI.
Re: Static Asset Compilation
#29Good tips. I've found that http://pngquant.org generates smaller pngs than optipng, but the former is lossy (reduced color palette). I can't tell the difference though.
E.g. if the PNG was 32 bit, and had a full color palette but was filled with a single 8 bit color. You could safely, and "loss-ily", convert the PNG to 8 bit and replace the entire color palette with the single entry for the color that is actually used.
That said, PNGQuant uses dithering so there will often be changes apparent if you perform a pixel by pixel comparison in code.
Just like you, I can't visually identify the difference between a PNGQuant image and the 'raw' PNG that was used to create it (at least not on any images that I've seen so far).
Re: Static Asset Compilation
#30Why is it safe to include a subset of the SHA1 digest instead of the whole digest? What's the reasoning behind this? Would it make sense to use a shorter hash (e.g. CRC32) instead if your filenames have to be that short?