4 ms·
To be precise, code caching has been in major browsers for a while, but it was in-memory cache. Chromium is the first to make it persistent with this update. Ye
by jray319 12y ago
To be precise, code caching has been in major browsers for a while, but it was in-memory cache. Chromium is the first to make it persistent with this update. Yet, what's cached contains no optimization result. It is more like basic parsing and translation into machine code.
- timdorr 12y agoIt looks like a logical next step is to store the optimized and compiled code. And after that, you can perform more aggressive optimizations on frequently-accessed scripts.
- diydsp 12y agoyeah if the pages stored hashes of the script, it could be pre-executed before you even visit the page. or common libs like jquery could be pre-parsed into binary structs in RAM.
- seba_dos1 12y agoIt needs to happen. It's so simple and effective approach that it's really puzzling to see it not being implemented anywhere.
- tajen 12y agoIs next step that Chrome accepts js in the form of precompiled binaries from websites? Sounds a bit futuristic, but compiling would be reduced to checking the security of the binary.
- azakai 12y agoIt is pretty hard to cache optimized JavaScript, I've been told, due to the generated code containing inline caches and other tricks. But at least in some cases it is possible, for example Firefox has had persistent code caching of asm.js content for a while now, https://blog.mozilla.org/luke/2014/01/14/asm-js-aot-compilation-and-startup-performance/ https://blog.mozilla.org/luke/2014/01/14/asm-js-aot-compilat... , which is the actual fully-optimized machine code.
- josteink 12y ago> To be precise, code caching has been in major browsers for a while, but it was in-memory cache. Chromium is the first to make it persistent with this update. Does this mean developers will need to put in (additional) efforts to do cache invalidation when they've updated their code?
- ohitsdom 12y agoDevelopers already have to account for caching, so this shouldn't change anything. Overriding the cache to roll out an update is generally done in 2 ways: 1) Changing the file name, so it's a completely new file to the browser and thus downloaded (usually by incrementing the version number, like myApp.1.0.1.js). 2) Setting different cache rules on the server for different file types. If the updates aren't critical, you can let the cache run it's course. So your cache rules could be 1 month for images, 1 day for HTML, and 1 hour for JS files.