Static Resources
Static resources and application space
setAppPath() selects the required application space: the directory tree containing the application resources Achieve makes available through HTTP. Ordinary static resources are resolved within this space, and request paths cannot escape its boundary.
Query strings are not part of filesystem lookup. Exact and subtree mappings can give a resource another public URL while keeping its actual location inside the application space. See the Routing Reference for mapping behavior and precedence.
Files ending in .jss, .jss.cjs, or .jss.mjs are executable JavaScript Servlets. Achieve executes them instead of returning their source. See Backend: JavaScript Servlets for servlet behavior.
Directories and default documents
A request for a directory without its trailing slash receives a 301 redirect to the slash form. Achieve preserves the complete query string in the redirect.
For a directory request, Achieve selects the first existing default document in this order:
index.htmlindex.htmindex.jssindex.jss.mjsindex.jss.cjs
The servlet forms are executed rather than returned as source. A resource that cannot be found normally receives 404 Not Found.
Content types
Achieve includes MIME mappings for common web, document, image, audio, and video file types. Use addMimeType() to register an ordinary static type and addAVMimeType() to register a media type.
Call showMimeTypes() before starting the server to display the registered MIME types in the startup output. Both ordinary static-resource and audio/video MIME mappings are included.
achieve.setAppPath("./application");
achieve.showMimeTypes();
achieve.listen(8989);
The showMimeTypes() call enables reporting; it does not change how resources are served.
The audio/video MIME table selects Achieve's media-streaming and byte-range handling. Other registered types use ordinary static-resource handling.
An unknown extension defaults to text/plain. Extension matching is case-sensitive. For a successful static response, Achieve uses the configured MIME value as the Content-Type without automatically appending a character set.
Caching and conditional requests
setCaching(true) enables advertisement of ETag and Last-Modified validators for static and media resources. An ETag identifies the selected representation, so identity, gzip, and deflate representations have distinct validators.
Achieve supports If-Match, If-Unmodified-Since, If-None-Match, and If-Modified-Since. Entity-tag and date preconditions are evaluated in their appropriate precedence order. Depending on the method and condition, evaluation can produce 304 Not Modified or 412 Precondition Failed.
setCaching(false) stops normal advertisement of cache validators, but it does not disable all conditional-request processing. Preconditions supplied by a client can still affect the response.
Byte ranges and media
Byte-range support applies to resources handled through the audio/video MIME table. Ordinary non-media static resources do not use this range-serving path.
Supported range forms include:
Range: bytes=100-199
Range: bytes=100-
Range: bytes=-100
A satisfiable range produces 206 Partial Content. A valid but unsatisfiable range produces 416 Range Not Satisfiable, while a malformed range produces 400 Bad Request. Achieve supplies Accept-Ranges, Content-Range, and Content-Length as appropriate.
Multiple range members do not produce a multipart/byteranges response. Achieve serves the first satisfiable range. Date-form If-Range is not supported and results in a full response. Other request preconditions are evaluated before range handling.
Compression
setCompress(true) enables compression for eligible ordinary static resources with text/* or application/* MIME types. Achieve supports gzip and deflate. Brotli is not supported, and media-streaming resources are not compressed.
Accept-Encoding determines representation selection. Achieve normally permits the identity representation unless the request excludes it, and sends Vary: Accept-Encoding where negotiation applies. If no acceptable representation is available, Achieve returns 406 Not Acceptable.
Achieve generates and maintains compressed representations in .compression-cache beneath the application space. Artifact generation requires filesystem write access. The first request may receive the identity representation while a compressed representation is generated; later requests can use the generated artifact.
The compression cache is internal. Direct HTTP access to its directory and contents is forbidden, including access through exact or subtree route mappings. Achieve's compression machinery continues to use the artifacts internally.
If a selected compressed artifact becomes unavailable before it is served, Achieve falls back to identity when identity is permitted. Response headers and validators then describe the identity representation actually returned.
HEAD requests and response headers
HEAD follows the same static-resource and representation selection as GET. It returns the appropriate status and metadata without response body bytes. Content-Length describes the selected representation.
A Range header does not make a media HEAD response partial. Directory redirects and conditional requests retain their appropriate redirect or conditional status.
Depending on the response, Achieve automatically supplies headers including:
Content-TypeandContent-LengthServerandDateETagandLast-Modifiedwhen applicableContent-EncodingandVarywhen compression negotiation appliesAccept-RangesandContent-Rangefor media range handlingLocationfor directory redirects
Not every header applies to every response. Successful ordinary static and media responses use the same Achieve Server header.
Missing resources and errors
404 Not Foundnormally identifies a missing resource.403 Forbiddenprotects the internal compression cache.406 Not Acceptablemeans no acceptable negotiated representation is available.500 Internal Server Errorcan report a relevant filesystem or serving failure.