Конфигурация Apache2 mod_cache с FallbackResource и соответствующим ключом кеша mod_dir - PullRequest
0 голосов
/ 03 декабря 2018

Конфигурация хоста Apache2 для данного экзамена

<VirtualHost *:80>
    ServerName mywebsite
    DocumentRoot ${APACHE_DOCUMENT_ROOT}

    # This is because the hostname of the virtual-host serving the content is
    # used within the cache key. With the setting set to On virtual-hosts with
    # multiple server names or aliases will not produce differently cached
    # entities, and instead content will be cached as per the canonical
    # hostname.
    UseCanonicalName On

    # Cache content before mod_deflate
    CacheQuickHandler off
    SetOutputFilter CACHE
    AddOutputFilterByType DEFLATE application/json

    # X-Cache header will be added to response with the cache status
    CacheHeader on

    CacheSocache memcache:${MEMCACHED_URI}
    CacheSocacheMaxSize 983040
    CacheEnable socache /

    <Directory ${APACHE_DOCUMENT_ROOT}>
        FallbackResource /index.php
        AllowOverride None
    </Directory>
</VirtualHost>

В этом случае при запросе /products?lang=en ключ кэша генерируется с путем /index.php?lang=en.Это означает, что /attributes?lang=en также будет иметь тот же ключ кеша.

Вот журналы для этого конкретного случая:

[Mon Dec 03 09:02:58 2018] [debug] [pid 18] cache_storage.c(666): [client 172.19.0.1:41618] AH00698: cache: Key for entity /index.php?lang=en is http://mywebsite:80/index.php?lang=en
[Mon Dec 03 09:02:58 2018] [debug] [pid 18] mod_cache_socache.c(496): (70015)Could not find specified socket in poll list.: [client 172.19.0.1:41618] AH02352: Key not found in cache: http://mywebsite:80/index.php?lang=en
[Mon Dec 03 09:02:58 2018] [debug] [pid 18] mod_cache.c(507): [client 172.19.0.1:41618] AH00757: Adding CACHE_SAVE filter for /index.php
[Mon Dec 03 09:02:58 2018] [debug] [pid 18] mod_cache.c(530): [client 172.19.0.1:41618] AH00758: Replacing CACHE with CACHE_SAVE filter for /index.php
[Mon Dec 03 09:02:58 2018] [debug] [pid 18] mod_cache.c(541): [client 172.19.0.1:41618] AH00759: Adding CACHE_REMOVE_URL filter for /index.php
[Mon Dec 03 09:03:00 2018] [debug] [pid 18] mod_cache.c(1348): [client 172.19.0.1:41618] AH00769: cache: Caching url http://mywebsite:80/index.php?lang=en for request /products?lang=en
[Mon Dec 03 09:03:00 2018] [debug] [pid 18] mod_cache.c(1354): [client 172.19.0.1:41618] AH00770: cache: Removing CACHE_REMOVE_URL filter.
[Mon Dec 03 09:03:00 2018] [debug] [pid 18] mod_cache_socache.c(1125): [client 172.19.0.1:41618] AH02387: commit_entity: Headers and body for URL http://mywebsite:80/index.php?lang=en cached for maximum of 1201 seconds.
[Mon Dec 03 09:03:00 2018] [debug] [pid 18] mod_deflate.c(853): [client 172.19.0.1:41618] AH01384: Zlib: Compressed 28116 to 3379 : URL /index.php
172.19.0.1 - - [03/Dec/2018:09:02:58 +0000] "GET /products?lang=en HTTP/1.1" 200 3397 "-" "curl/7.58.0"

Как настроить Apache2 для генерации ключей кеша с фактическим запрошенным путем

...