mirror of
https://codeberg.org/VnPower/PixivFE
synced 2024-12-06 19:16:23 +01:00
docs: update caching section
This commit is contained in:
+1
-1
@@ -139,7 +139,7 @@ func (s *ServerConfig) LoadConfig() error {
|
||||
s.APIMaxBackoffTime = 8000 * time.Millisecond
|
||||
|
||||
s.CacheSize = 100
|
||||
s.CacheTTL = 5 * time.Minute
|
||||
s.CacheTTL = 60 * time.Minute
|
||||
s.CacheShortTTL = 10 * time.Second
|
||||
|
||||
s.ResponseSaveLocation = "/tmp/pixivfe/responses"
|
||||
|
||||
+1
-1
@@ -166,7 +166,7 @@ func retryRequest(
|
||||
// Check for X-Handled-Redirected in the incoming request
|
||||
if redirectedHeader := incomingHeaders.Get("X-Handled-Redirected"); redirectedHeader != "" {
|
||||
// fmt.Printf("retryRequest: X-Handled-Redirected header found: %s\n", redirectedHeader)
|
||||
if strings.Contains(strings.ToLower(redirectedHeader), "no-cache") {
|
||||
if strings.Contains(strings.ToLower(redirectedHeader), "true") {
|
||||
// fmt.Println("retryRequest: X-Handled-Redirected found, removing existing cache entry if present")
|
||||
// Remove existing cache entry if present
|
||||
cacheLock.Lock()
|
||||
|
||||
@@ -199,12 +199,11 @@ Maximum backoff time for token management.
|
||||
|
||||
## Caching configuration
|
||||
|
||||
PixivFE caches responses from the Pixiv API to improve performance. The following environment variables can be used to configure the caching behavior.
|
||||
PixivFE implements a caching system for API responses to improve performance. The cache uses a [Least Recently Used (LRU) eviction policy](https://en.wikipedia.org/wiki/Cache_replacement_policies#Least_Recently_Used_(LRU)).
|
||||
|
||||
!!! note
|
||||
While caching improves performance, it also means that changes on Pixiv might not be immediately reflected in PixivFE.
|
||||
Each cache entry is stored with an expiration time. When a cached item is accessed, its expiration time is checked. If the item has expired, it is treated as a cache miss, and a new request is made to the Pixiv API.
|
||||
|
||||
If you want content updates that are closer to real-time, consider reducing the cache TTLs.
|
||||
To ensure that responses are properly isolated between different users, the cache key for each item is generated based on both the URL of the request and the user's `pixivfe-Token` cookie.
|
||||
|
||||
### `PIXIVFE_CACHE_SIZE`
|
||||
|
||||
@@ -212,15 +211,15 @@ PixivFE caches responses from the Pixiv API to improve performance. The followin
|
||||
|
||||
**Default:** `100`
|
||||
|
||||
Specifies the maximum number of items that can be stored in the cache. This limits the memory usage of the cache.
|
||||
Specifies the maximum number of items that can be stored in the LRU cache. This limits the memory usage of the cache. When the cache reaches this size, the least recently used items will be evicted to make room for new entries.
|
||||
|
||||
### `PIXIVFE_CACHE_TTL`
|
||||
|
||||
**Required**: No
|
||||
|
||||
**Default:** `5m`
|
||||
**Default:** `60m`
|
||||
|
||||
Specifies the Time To Live (TTL) for cached items. This is the duration for which an item remains valid in the cache before it's considered stale and needs to be fetched again.
|
||||
Specifies the default Time To Live (TTL) for cached items. This is the duration for which an item remains valid in the cache before it's considered stale and needs to be fetched again from the Pixiv API. The TTL is applied to most API responses and can safely be set to a high value.
|
||||
|
||||
### `PIXIVFE_CACHE_SHORT_TTL`
|
||||
|
||||
@@ -228,7 +227,13 @@ Specifies the Time To Live (TTL) for cached items. This is the duration for whic
|
||||
|
||||
**Default:** `10s`
|
||||
|
||||
Specifies the Time To Live (TTL) for cached items when matching one of the `shortTTLPaths`.
|
||||
Specifies a shorter Time To Live (TTL) for specific API endpoints that change frequently. This shorter TTL is applied to the following paths:
|
||||
|
||||
- `/ajax/discovery/artworks` (used for the `/discovery` page)
|
||||
- `/ajax/discovery/novels` (used for the `/discovery/novels` page)
|
||||
- `/ajax/illust/new` (used for the `/newest` page)
|
||||
|
||||
These paths are considered more dynamic, and the shorter TTL ensures more up-to-date content.
|
||||
|
||||
## Network proxy configuration
|
||||
|
||||
|
||||
Reference in New Issue
Block a user