Comments (8)
Do you suggest using Git's integrated hash?
from express-cdn.
The approach I used on my fork is simply to perform something like this:
var hash = crypto.createHash("md5");
// ...
for (var b=0; b<assets.length; b+=1) {
// ...
hash = hash.update(fs.readFileSync(path.join(options.publicDir, assets[b])));
// ...
}
// ...
return createTag(src, "/" + name, attributes) + "\n";
The problem with this approach at the moment is that it is computationally intensive and time consuming to generate an MD5 digest of a bunch of files every time you want to generate an HTML tag. I'm guessing that the best approach is to generate the MD5 digest only once and cache it in memory.
Here is my commit with this naive implementation:
andrewdeandrade@3e2744a
I'm going to contact bminer and check if he'd be interested in modularizing his node-static-assets module to separate the express middleware from the cache strategies.
Tell me more about what you had in mind regarding the git integrated hash approach. I'm not sure I understand. Do you have a link to an implementation?
from express-cdn.
Nick, here's a naïve implementation.
https://github.com/malandrew/express-cdn
It's not production ready as I need to go ahead and modify the middleware part so it caches values and doesn't recalculate on every server request. Any ideas on how you'd go about implementing that caching?
Once I figure out how best to implement this, I want to go ahead and add this to the less-middleware module since it's also got the mtime achille's heel that is the source of edgecase bugs.
from express-cdn.
Andrew,
Sorry for delay -- been working hard on my startup -- if you do a pull
request I have no problem looking it over!
Someone integrated CSS for url(...)
attribute in the newest version of
express-cdn v0.0.6 -- check it out.
It needs the appended mtime to the image though, might you look into that?
That was one of the lazyweb requests.
On Tue, Sep 11, 2012 at 12:44 AM, Andrew de Andrade <
[email protected]> wrote:
Nick, here's a naïve implementation.
https://github.com/malandrew/express-cdn
It's not production ready as I need to go ahead and modify the middleware
part so it caches values and doesn't recalculate on every server request.
Any ideas on how you'd go about implementing that caching?Once I figure out how best to implement this, I want to go ahead and add
this to the less-middleware module since it's also got the mtime achille's
heel that is the source of edgecase bugs.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/16#issuecomment-8446953.
from express-cdn.
Andrew, couldn't you set once:true on the middleware to only have it generate the compiled css once? I believe the problem is that express-cdn goes straight to disk to find the css files without requesting it through the middleware, no?
from express-cdn.
@grydstedt for CSS we do a GET request https://github.com/niftylettuce/express-cdn/blob/master/lib/main.js#L279 -- if that answers your question? /cc @malandrew
from express-cdn.
we should take care of this issue, timestamps aren't too cool right now. @grydstedt did you have any ?'s about how CSS gets requested or anything?
from express-cdn.
adding to lazyweb requests in the readme, I think git sha might be better/easier
from express-cdn.
Related Issues (20)
- Express CDN doesn't support video/mp4
- Error when installing express-cdn HOT 2
- Error during install on node 6 due to outdated optipng-bin and jpegtran-bin dependencies HOT 2
- Files do not upload to s3 HOT 2
- BUG : removing the first character of file path HOT 1
- production true is giving errors
- Action required: Greenkeeper could not be activated 🚨
- When Uglify fails, it doesn't tell which file is failing it. HOT 1
- Older version of clean-css leaving truncated files HOT 1
- Error: TypeError: assets.substr is not a function
- Getting error after latest update HOT 2
- File file.js comes to S3 without content. HOT 2
- 0.31 and 0.32 releases are broken by UglifyJS 3.X HOT 2
- In package.json update dependency on 'request' module to 2.88.0
- BUG: timestamp cache not set properly
- Concatenating files doesn't produce a URL-encoded CDN address HOT 2
- Working with vars
- Explicitly define list of assets HOT 1
- Private bucket support
- Asset versioning in production HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from express-cdn.