Skip to content
This repository was archived by the owner on Aug 4, 2025. It is now read-only.

Conversation

@Vispercept
Copy link

Enable the possibility to set max-age for static files

Thomas König and others added 4 commits January 26, 2016 10:00
@boutell
Copy link

boutell commented Jan 26, 2016

What will this do if no configuration is passed in?

How does it interact with the existing express.static call?

And does it make sense to configure appy for better production static file
serving? nginx is always going to outperform it, for sure... that's why our
standard recommendation for Apostrophe involves a frontend proxy:

http://apostrophenow.org/howtos/production.html

On Tue, Jan 26, 2016 at 7:01 AM, Thomas König [email protected]
wrote:

Enable the possibility to set max-age for static files

You can view, comment on, or merge this pull request online at:

#9
Commit Summary

  • Include serve-static module to make it possible to set the
    Cache-Control-Header of static files
  • Merge pull request Update appy.js #1 from
    sueddeutsche/feature-SZINT-2792-serve-static-max-age

File Changes

Patch Links:


Reply to this email directly or view it on GitHub
#9.

*THOMAS BOUTELL, *DEV & OPS
P'UNK AVENUE | (215) 755-1330 | punkave.com

@Vispercept
Copy link
Author

Hey Tom!

If one wouldn't pass the serveStaticOptions to appy, nothing changes. Static files would be served with a Cache-Control-Header which says: max-age: 0.

You are right, serving static files with nginx would be a way much better solution, but unfortunately we are not able to this in our case. So the only way to cache these files is to do this over the CDN, and therefore it is necessary to set the Cache-Control-Header to max-age: 31536000.

@boutell
Copy link

boutell commented Feb 10, 2016

For bc reasons I'm leery of switching to a different module to provide
static file serving. appy is based on Express 3, which does not use
serve-static under the hood. However, express.static in Express 3 does
take an optional "options" object, and that object does support a MaxAge
option, check it out in the Express source (it's under-documented on the
site).

So a more minimal and safe change would be to add a staticOptions property
that gets passed as the second argument to express.static if it exists.

On Wed, Feb 10, 2016 at 2:59 AM, Thomas König [email protected]
wrote:

Hey Tom!

If one wouldn't pass the serveStaticOptions to appy, nothing changes.
Static files would be served with a Cache-Control-Header which says: max-age:
0.

You are right, serving static files with nginx would be a way much
better solution, but unfortunately we are not able to this in our case. So
the only way to cache these files is to do this over the CDN, and
therefore it is necessary to set the Cache-Control-Header to max-age:
31536000.


Reply to this email directly or view it on GitHub
#9 (comment).

*THOMAS BOUTELL, *DEV & OPS
P'UNK AVENUE | (215) 755-1330 | punkave.com

@Vispercept
Copy link
Author

Hey Tom,

you're right. That would be easier. Although we need to pass an other object to the express.static call...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants