TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Static Asset Compilation

48 点作者 autoref超过 12 年前

15 条评论

coenhyde超过 12 年前
Fairly 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.
评论 #4514350 未加载
评论 #4528056 未加载
voidfiles超过 12 年前
With such a complicated system I think you are missing out on the most signifcant speed optimization technique; reducing http requests.<p>For reference: <a href="http://developer.yahoo.com/blogs/ydn/posts/2007/04/rule_1_make_few/" rel="nofollow">http://developer.yahoo.com/blogs/ydn/posts/2007/04/rule_1_ma...</a><p>It's laudable that you are paying attention to caching, but you don't compile all your files in to one file. It seems like you could pick up a lot ground here by at least concating all css into one file, and js in to one file.<p>Also you could load jquery from the Google AJAX API endpoint. That way the users has a higher chance of having already loaded jQuery.<p>Also using the same CSS/JS products across multiple pages would help.
评论 #4514211 未加载
eli超过 12 年前
You 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 "?&#60;your_hash_here&#62;" 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 <i>ancient</i> references to a file (a logo someone hotlinked, for example) will still render rather than 404, so long as the name hasn't changed. No need to keep tons of old revisions of files around.
评论 #4514320 未加载
评论 #4514766 未加载
captn3m0超过 12 年前
Could someone say if using HttpGzipStaticModule really helps? Gzipping small static resources on-the-fly should not take down your cpu by much.<p>Surely a nice thing to have, but does it help?
howardr超过 12 年前
I found that renaming CSS file names using the hash of the contents does not always work because any changes to dependencies (e.g. images) won't always bubble up to the CSS. I forget all of the reasons why it didn't always work, but it I think it had to do with CDN invalidation for files that I could not-rename (e.g index.html).<p>The process I use computes the hash of every file and creates a dependency map then I use the hash of the contents of a file and its dependencies to rename the file.
评论 #4514061 未加载
nestlequ1k超过 12 年前
Can someone with knowledge of both this and rails 3.1 explain the difference. Seems very similar.
评论 #4514215 未加载
评论 #4514109 未加载
moonboots超过 12 年前
Good tips. I've found that <a href="http://pngquant.org" rel="nofollow">http://pngquant.org</a> generates smaller pngs than optipng, but the former is lossy (reduced color palette). I can't tell the difference though.
评论 #4514659 未加载
rthprog超过 12 年前
Aside from minifying javascript, you should probably also consider using Google's Closure Compiler in 'Advanced-Compilation' mode. I believe it does a much better job than traditional minification.<p><a href="https://developers.google.com/closure/compiler/docs/api-tutorial3" rel="nofollow">https://developers.google.com/closure/compiler/docs/api-tuto...</a>
brown9-2超过 12 年前
Is putting hash digests in filenames really easier than sending <i>Last-Modified</i> headers in the response, parsing If-<i>Modified-Since</i> headers and returning 304 when applicable, and/or using ETags?<p>I would have thought that most web frameworks do all these things for you automatically by now.
评论 #4514349 未加载
malyk超过 12 年前
We use the git commit hash of the checkin that is pushed to production as part of the folder structure for our assets. Has worked really well for us.<p>It does mean we use more space on s3 though, but it guarantees we won't miss re-seeding some of the files.
评论 #4514269 未加载
ryetoasthumor超过 12 年前
Interesting series <a href="http://autoref.com/blog/2012/09/07/the-tech-behind-autoref-part-1-our-stack/" rel="nofollow">http://autoref.com/blog/2012/09/07/the-tech-behind-autoref-p...</a><p>Full disclosure (bizdev at AutoRef)
cbhl超过 12 年前
Why 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?
评论 #4514703 未加载
csense超过 12 年前
You could probably shave a few bytes off your URL's, while achieving the same collision resistance (or alternatively increase the collision resistance in the same number of bytes) if you base64 encoded the hash.
dazbradbury超过 12 年前
If you're using .net, RequestReduce [1] is an excellent tool for managing your static assets.<p>[1] - <a href="https://github.com/mwrock/RequestReduce" rel="nofollow">https://github.com/mwrock/RequestReduce</a>
评论 #4514203 未加载
评论 #4515124 未加载
kmfrk超过 12 年前
Is ImageOptim still a good choice to go with? I really like the simplicity of the GUI.
评论 #4514654 未加载
评论 #4514853 未加载