Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Express Basics Serving Static Files in Express What Are Static Assets?

Alexander Perry
seal-mask
.a{fill-rule:evenodd;}techdegree
Alexander Perry
Front End Web Development Techdegree Student 11,395 Points

Does the static server send the static assets again after every request?

Does the static server send all of the static assets in repsonse to every request? Or does it know which ones the current route will need? Or is it neither of those? Thank you in advance for any help!

1 Answer

I may be wrong, so someone please correct me if I'm wrong, but since no one replied yet, I'll try to answer this as well as I can.

As far as I know, you share a specific folder with the express static middleware. This will allow you to request any file within the folder, as long as you know the path. You will usually only request one file at a time, but a page can of course request multiple files to display or use.

I am not sure if the static files will be cached, but I think they do get cached by default.