Knowledgebase

Serving Static Files Print

  • python, caching, performance, uploads, guide, howto, solution, zillionkinghost
  • 0

Images, styles and scripts.

WHAT STATIC FILES ARE

Files served as they are: images, stylesheets, scripts, fonts.

WHY THEY MATTER

They are most of what a page loads.

WHAT NOT TO DO

Serve them through your Python application in production.

WHY

It is slow and consumes application processes for work the web server does better.

WHAT TO DO INSTEAD

Have the web server serve them directly.

WHAT TO CONFIGURE

Caching headers, so browsers do not request them repeatedly Compression

WHAT TO DO ABOUT CHANGED FILES

Include a version in the filename or address, so caching does not serve an old copy.

THAT POINT

The reason a change to a stylesheet appears not to take effect.

WHAT TO OPTIMISE

Image sizes, before uploading Number of files requested

WHAT TO CONSIDER FOR VISITORS FAR AWAY

A delivery network.

WHAT TO KEEP OUT OF THE STATIC DIRECTORY

Anything not intended to be public.

Everything in it is downloadable by anyone.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot