Static files
Static files are simple files that rdfpub serves exactly as they are. Any file
that isn't an RDF, SPARQL, or Handlebars file gets copied to the output
directory as a static file which can be accessed via its URL the way that you'd
expect. This site puts all of
its static resources
in a dedicated static
folder, but you can put them anywhere in your site's
directory structure, such as in the directory of a resource that a static file
belongs to.
The site configuration attempts to send a Content-Type
header that is
appropriate for common file types according to
its list of MIME types
which covers a good majority of common file types served from the web. Any file
type that isn't listed gets served as plain text (text/plain
MIME type).
Compression
As of
rdfpub generator version 2.3.0,
static files can be compressed during the build process and served
transparently to browsers. This can significantly improve your site's speed as
well as reduce bandwidth usage from your site. It's generally recommended to
compress as many files as possible that would benefit from compression.
As explained in the configuration lesson,
some types of files benefit greatly from compression while other types of files
are possibly hindered by compression. The general rule of thumb is that text
files are good canditates for compression while binary files are not good
candidates.
Examples of common file types that are best compressed:
- CSS files (.css)
- JavaScript files (.js)
- HTML files (.html, .htm)
Examples of common file types that shouldn't be compressed:
- Image files (.png, .jpg, .gif, .webp)
- Binary files (.exe)
- Files that are already compressed (.zip, .rar, .gz)
Caveats
Static files are very simplistic and they do not enjoy the same benefits of
type and language negotiation that resources do. If you need to support static
files for alternate languages or file formats, you'll need to provide each
alternate as a separate file.