Open Swaagie opened 11 years ago
We should take in mind that Internet Explorer has rather painful limitations when it comes to adding CSS dynamically to the page.
So implementing this could lead to potential disasters, so I don't know if it's worth the time and effort to implement this.
Which version of IE are we talking about and how high is the risk of this actually happening. If you go from 1 style per pagelet, someone would have to do that many pagelets in one page, which sounds a bit unlikely to me.
IE 6/7/8 i dont know about 9/10/11 as they changed some stylesheet limitations
Sent from my iPhone
On Jul 22, 2013, at 8:07 AM, Martijn Swaagman notifications@github.com wrote:
Which version of IE are we talking about and how high is the risk of this actually happening. If you go from 1 style per pagelet, someone would have to do that many pagelets in one page, which sounds a bit unlikely to me.
— Reply to this email directly or view it on GitHub.
The limit has been removed in IE10: http://blogs.msdn.com/b/ieinternals/archive/2011/05/14/internet-explorer-stylesheet-rule-selector-import-sheet-limit-maximum.aspx and set the limit to 4095 stylesheets per document.
i think localStorage makes sense! i've been wondering how to do the same, some thoughts i've had:
the data that will be necessary to store in localStorage seems to be:
these both have pros and cons and can be used in isolation or mixed by the caching mechanism. (not sure how much you care about one or the other).
There are JS utils to help with caching files in the browser, that use localStorage by default, & will use other storage methods for fall backs on older browsers. Would using an outside util, rather than baking in the function, be better?
Yes localStorage makes sense. But there are couple of reasons of why localStorage would not be an option in every browser:
@okayzed
I don’t think that a timestamp would be needed in the localStorage if we’re already providing it with an hash. This hash could also be used as an id.
As we’re already sending the file names (which are hashes of the content) to the server we can simply check if the hash is available in localStorage. When it is, we could serve that instead of doing a server request. So I think that an non-prioritized
cache check might make more sense for us.
As for enforcing asset freshness, i’ve been looking at DynoSRC: https://github.com/DynoSRC/dynosrc to see if that would be a solution for us. An alternate and older solution like DynoSRC is diffable which is something that the Google Maps was/is using for their assets: http://www.stevesouders.com/blog/2010/07/09/diffable-only-download-the-deltas/
This might be a great solution for this whole issue as it would already cache assets locally and only transfer the diff
to the client.
@3rd-Eden the timestamp is to help with resolving the case of two (or more) open tabs trying to write their versions to localStorage. the timestamp lets each tab know if their version is the newest or not. otherwise, there might be a sync war while they try to figure out who's version of the site is right. (just having hash makes it difficult to know which version to evict from storage).
i use 'local storage' loosely, but i menerally gean 'client storage', whether it is indexdb, localStorage, sqlite, what have you.
re: dynosrc: it looks really cool but is still a layer above the storing in client storage optimizations. (let's call it the 'sync assets to server' version layer and can be implemented on top of whichever solution :-)
a thought off the top of my head is: how important is sending 'diff' updates? it makes sense when using large bundles (or huge libs, like highcharts, jquery, etc), but if each module of the app is cached in localStorage, will it be a big deal? i'm thinking that most modules will not be larger than 1 - 5K, unless they are vendor libraries.
another note is (maybe importantly): won't it grow really large to be able to fast forward any number of clients to the current version? it seems a nightmare to maintain the database of diffs unless some severe restrictions are placed on the recency of modules that you are allowed to fast forward.
Ideally we would like to have the browser cache each CSS/JS resource. This could be done by just supplying a CSS/JS file, but this is suboptimal as each file will trigger request overhead.
Bundling
script
orstyle
tags on the other hand will prevent any caching. Resulting in newAs pagelets will require html5 anyway,
localStorage
seems like an ideal candidate, but there are some caveats, like: