On Fri, Aug 3, 2012 at 5:16 PM, Tim Caswell <[email protected]> wrote:
> What kind of caching do you want?
Actually it's just one file that needs *caching* and *compression*:
http://example.com/xyz.js
The other files are just exposed for development (process.env.NODE_ENV
!== 'production'):
http://example.com/scripts/*.js
And, then I want to provide Socket.IO. Fortunately, the Socket.IO module
is taking care of serving itself.
What is all this? It's an API that users interface with via an object
provided by `xyz.js`. In a way it's similar to the YouTube API. There
you first load some JavaScript, and then you interact with the `YT`
object, to: load a new video, play it, stop it, etc.
The contents of the directory `script` are a bunch of AMD modules. They
are the building blocks of `xyz.js`.
> And are you also talking about conditional http requests (Etag,
> timestamps, 304 responses)? What about range request support?
Nothing complicated - see above. No redirects, no error page, etc.
> A simple filter in front of any off-the-shelf static file server
> should five you 95% of what you want.
I don't want to use a separate file server.
> var staticHandler = require('creationix').static("/", __dirname);
Looks interesting! Reading the source of `static()`...
> Then you'll mount / -> / but only if it ends in ".js" and is not
> app.js.
There are more files that I don't want to serve in `/`. In fact, for
security reasons, I don't want to mount `/` at all...
> If you don't mind caching your files in memory, then just read the
> files to ram (either at startup or on demand) and watch the files for
> changes (if you want to pick up changes) to invalidate your cache.
I see. That's a start for `xyz.js`. I could just use `fs.watchFile`.
Then I also need to think about compression. But perhaps the Nodejitsu
folks take care of that.
> Don't fall into the trap of using a large library that only does 50%
> of what you [...]
OTOH I don't have any special requirements, and so writing my own static
file serving code - while surely instructional - seems like reinventing
the wheel.
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en