Forums

HTTP caching headers for static content?

Currently static files aren't cached at all which is a major drag on frontend performance, especially if you have many mobile users. Is it possible to setup a directive for caching static content for a month or so? It really slows down the whole user experience.

Also can you tweak the ssl settings with fore instance "ssl_session_cache shared:SSL:10m". It seems like every second or third time it has to reinitiate ssl handshake. Tweaking this with some caching could alleviate this.

Also, when I got you. Is there a way to gracefully reload you site without it going offline for a few seconds?

Else great product.

We currently have really short caching at the nginx level because we want to cater to users with wide ranges of requirements (eg: if they are constantly changing their files and need to serve it fresh, or they are developing and want to see instant changes). Will have to think about how to fit both users.

We just put a change to the ssl_session_cache into our integration loop. That should hopefully be deployed soon, so you may see better performance in terms of renegotiating ssl handshakes.

We currently do graceful reload- when your webapp restarts, we finish serving all the requests that it has received. However, you may be seeing some errors on new requests that are made during your webapp spinup post-reload. We used to respond with 302 redirects to keep it looping until your webapp is finished spinning up. However, this had some unexpected consequences and we took that out. I have raised a ticket to look into how to introduce this again.

Cool. Developers can either do the following, if they don't already have some sort of cache breaking (altering file names or query strings ?version=0.1):

  • do a hard reload of the browser to get the latest static files
  • add a version query string to static files (fore instance main.css?version=0.1)

Other than that I think most frontend developer stacks have a build in cache breaker or it can be implemented easily with gulp or grunt. Other than that I have also developed on wpengine and they also cache static files (to which you just do a hard reload - cmd + shift + r)

A graceful reload would be appreciated - it can be difficult to go off line if you have some important tasks runnig. Perhaps just change the reload to an actual graceful reload?

Hi Lata- just edited the answer above with some comments from my colleague.

Yes definitely understand the point that it is easy to cache break etc- this is definitely something we are doing where we are catering to new beginners who might be confused initially. We hope to add a way to allow users to customize this at some point.

In the mean time, will investigate more in terms of the caching time for those static assets and see if we can tweak it.

Any caching time would be highly appreciated for running production :-). As stated, apps in development can just do a hard reload and the latest files.

By the way, just want to let you know that we have bumped that up to ssl_session_cache shared:SSL:100m in a deploy a couple weeks ago.