Cache & Session Configuration
Within BookStack specific data is cached server-side to increase performance in certain areas. Sessions are used for storing visitor-specific details, to allow things such as persisting user logins. Both of these mechanisms have various control options, and both use the local filesystem by default.
Cache & Session Storage
By default BookStack will use a file system cache that’s storage in the storage/framework
folder. This is also used to store user session data. Below are some alternative systems that can be used for caching & sessions.
Database
As an easy alternative to using the filesystem, you can use the database to store the cache and session. The database setup for this is done when installing/updating BookStack so you simply need to add or update the following in your .env
file:
Memcached
To use memcached for caching and/or sessions open up your .env
file and add, or update if existing, the below options:
You will also need to add a variable to specify the memcached servers you are using. To do this add a variable named MEMCACHED_SERVERS
to the .env
file and set the value to be your memcached servers in the following format: HOST:PORT:WEIGHT,HOST2:PORT:WEIGHT
. You can specify as many servers as you want. Their usage split will be determined by the weight given to them. Here are some examples of this option in .env
format:
Redis
To use Redis for caching and/or sessions open up your .env
file and add, or update if existing, the below options:
You will need to add a variable to specify your Redis servers. To do this add a variable named REDIS_SERVERS
to the .env
file and set the value to point at your Redis servers in the following format: HOST:PORT:DATABASE,HOST2:PORT:DATABASE
. The default values for each host are 127.0.0.1:6379:0
. You can list as many servers as you like. If your redis servers are password protected you can use the format HOST:PORT:DATABASE:PASSWORD
.
If more that one server is provided they will automatically be clustered by BookStack to perform client-side sharding across your Redis nodes, allowing them to pool together for a large amount of RAM. This disadvantage of this it that it does not allow for fail-over.
Here’s a couple of examples of the REDIS_SERVERS
option in .env
format:
Session Cookie Configuration
Browser cookies are used to track sessions when using BookStack. The following session cookie options can be added to your .env
file:
|
|
Session Timeouts
Sessions, and therefore user logins, have a pre-set timeout before they expire. If there’s no activity during this timeout period, the session will no longer be active, and the user may need to log in again. This timeout period resets upon most system activities where the browse URL changes.
This timeout is set to 2 hours by default, but can be configured in your .env
file as shown below: