Pragmatic, automatic, let's get static
First and foremost, Raze assumes that your static folder is, well, static. This means that by default, it assumes that your static directory is unchanging. With this assumption, some major optimizations can be made.
If you want to add or remove files in the static directory during runtime, this is possible and easy to enable (while still achieving Raze's optimizations). Read the Dynamic Static-Directories section below.
Accessing Static Files
By default, static files are served from the
static directory. The word
static is excluded from the path. So if you have a file named
styles.css in a
stylesheets folder in the
static directory like so:
my_app │ ├— src │ ├— static │ ├— stylesheets │ ├— styles.css
...then to fetch that file, you would would hit
Changing the Static Directory Path
The static directory can be changed via the
Raze.config.static_dir = "./public"
Dynamic - characterized by constant change, activity, or progress Static - lacking in movement, action, or change Oxymoron - a figure of speech in which contradictory terms appear in conjunction
For Raze to recognize file additions or deletions in the static directory, you need to specify a subset of the static directory to match against the path.
For example, if you know that you will add and/or remove images in the
./static/images directory, you would let Raze know like so:
Raze.config.dynamic_static_paths << "/images"
So any paths that start with
/images/users/user1234/profile.png), Raze now knows to at least check if it is an existing static asset. Otherwise, Raze will rely on the static indexing that it does on startup.
Disabling Static Indexing
Static indexing is where Raze will remember the paths to all of the static assets on startup for quicker file serving. If static indexing is disabled, then for each and every request, Raze will perform an IO operation to check if the path is a reference to a static asset.
To disable static indexing, do:
Raze.config.static_indexing = false
The above is the same as doing the following:
Raze.config.dynamic_static_paths << "/"