user4083185
user4083185

Reputation:

Serving static files with Node.js and AngularJS

I have a very very simple node server, which has one task : serve an HTML file corresponding to the entry point of my AngularJS app.

But I have a problem : I have no cache for static resources, as JS or CSS files. How could I achieve it ? Is it a node or angular problem ?

Upvotes: 2

Views: 2268

Answers (1)

Bardi Harborow
Bardi Harborow

Reputation: 1888

AngularJS is a client-side framework, and has little to do with the serving of files. Can you not just use Express like this:

var express = require('express');
var app = express();

app.use(express.static(__dirname + '/public'));

app.listen(process.env.PORT || 3000);

As a side note, it may be more useful to serve static files with something like Nginx.

Upvotes: 4

Related Questions