> For the complete documentation index, see [llms.txt](https://docs.fortifiedid.se/resources/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fortifiedid.se/resources/resources.md).

# Resources

## Introduction

Use the Resources module to publish static content ("resources") from the local filesystem using HTTP.

Multiple instances can be configured and deployed to publish content from different directories.

This module is also used internally by other modules (like AuthN) to provide support for static content.

## Configuration

{% hint style="info" %}
**Module name:** `Resources`
{% endhint %}

The Resources module deploys a Resource module for each configured resource.&#x20;

The Resource module is a HttpModule and supports all common http configuration properties. Configuration properties for context (`http_context`) and CORS (`http_cors`) available on module level are passed on to each resource.

{% tabs %}
{% tab title="Properties" %}

| Name                                         | Description                                                                                                        |
| -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| `http_context`                               | Web context path of module. All resources will share this context (mandatory).                                     |
| `http_cors`                                  | CORS configuration for all resources (optional).                                                                   |
| `resources`                                  | Array of resource configuration objects.                                                                           |
| `resources[*].context_path`                  | Relative context path of resource. This value will be combined with module context to form the actual context.     |
| `resources[*].webroot_dir`                   | Directory from where files are served. All files in this directory and subdirectories are available (if readable). |
| `resources[*].overlay_dir`                   | Web root overlay directory. (optional; if not configured overlay is disabled)                                      |
| `resources[*].public`                        | Flag controlling if resources provided by this module are public or requires an authenticated session.             |
| `resources[*].enable_precompression`         | Flag to enable/disable support for pre-compressed resources. (default: `false`)                                    |
| `resources[*].enable_precompression_overlay` | Flag to enable/disable support for pre-compressed overlay resources (default: `false`)                             |
| {% endtab %}                                 |                                                                                                                    |

{% tab title="Example" %}

```
{
    "http_context": "/r",
    "resources": [
        {
            "context_path": "/pub",
            "webroot_dir": "htdocs/public",
            "public": true,
            "enable_precompression": true
        },
        {
            "context_path": "/private",
            "webroot_dir": "htdocs/private",
            "public": false,
            "http_auth_redirect_url": "/r/login"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

### Pre-compressed resources

Pre-compression means that a resource/file compressed in advanced and available in webroot/overlay is served instead of the version requested by the user-agent. From the user-agents perspective this works just like regular (inline) compression but it saves up resources on the server

Pre-compression is activated when the user-agent tells the server it supports it by sending the appropriate request header.

```
// Example requets header specifying support for gzip compression
Accept-Encoding: gzip
```

This header contain one or more encoding types that is supported by the user-agent.

If a compressed file exist, with the correct extension (see below), this file will be returned with the appropriate response header.

```
// Response header specifying that content is compressed usign gzip
Content-Encoding: gzip
```

The following encodings (compressions) are supported:

| Encoding type | File extension | Description |
| ------------- | -------------- | ----------- |
| br            | .br            | Brotli      |
| gzip          | .gz            | Gzip        |
|               |                |             |

To disable pre-compression the user-agent can send the following request header:

```
X-Precompressed-Content: false
```

When a response contains pre-compressed content the following response headers are returned (for debugging):

```
X-Precompressed-Content: true
X-Precompressed-Path: <request-path-to-precompressed-file>
X-Precompressed-Encoding: <precompress-encoding>
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.fortifiedid.se/resources/resources.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
