feat: Implementa Pseudo-CDN Engine para compartilhamento de cache global
This commit is contained in:
parent
859d0851e5
commit
3878c1d9ed
|
|
@ -3,5 +3,6 @@
|
|||
# O isolamento é garantido pela 'proxy_cache_key' que inclui o $host.
|
||||
proxy_cache_path /var/cache/nginx/dynamic_cache levels=1:2 keys_zone=dynamic_cache:100m max_size=20g inactive=7d use_temp_path=off;
|
||||
|
||||
# Default Cache Key (Unicidade garantida por Protocolo + Método + Host + URI)
|
||||
proxy_cache_key "$scheme$request_method$host$request_uri";
|
||||
# Default Cache Key (Inteligente: Isolada por Host ou Global para CDN)
|
||||
# Definida dinamicamente no security_maps.conf
|
||||
proxy_cache_key $pathfinder_cache_key;
|
||||
|
|
|
|||
|
|
@ -125,3 +125,22 @@ map $request_uri $cache_asset_ttl {
|
|||
# Padrão: Sem Cache
|
||||
default off;
|
||||
}
|
||||
|
||||
# --- Pathfinder Pseudo-CDN Engine ---
|
||||
|
||||
# 1. Identificação de Assets Globais (Idênticos em todos os sistemas)
|
||||
map $request_uri $is_global_asset {
|
||||
default 0;
|
||||
# Bibliotecas Comuns (Fingerprinted ou Versão Fixa)
|
||||
~*(jquery|bootstrap|fontawesome|axios|vue|react|alpine|htmx|inter|roboto).*\.(js|css|woff2?|ttf|otf)$ 1;
|
||||
# Pastas de Ativos Compartilhados (Convenção interna)
|
||||
~*(/cdn/|/shared/|/common/) 1;
|
||||
}
|
||||
|
||||
# 2. Chave de Cache Inteligente (Isolation vs Sharing)
|
||||
# Se for Asset Global -> Chave sem $host (Efeito CDN)
|
||||
# Se for Normal -> Chave com $host (Isolamento total)
|
||||
map $is_global_asset $pathfinder_cache_key {
|
||||
0 "$scheme$request_method$host$request_uri";
|
||||
1 "$scheme$request_method$request_uri";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue