AdguardTeam / AdguardTeam/AdGuardHome

ETag comparison

Abierto
#7,050 1 comentario 1 reacción 0 asignados Ver en GitHub
enhancement performance
Lenguaje dominante
TypeScript
Estrellas
36.9k
Forks
2.5k
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

### Prerequisites

- [X] I have checked the [Wiki](https://github.com/AdguardTeam/AdGuardHome/wiki) and [Discussions](https://github.com/AdguardTeam/AdGuardHome/discussions) and found no answer

- [X] I have searched other issues and found no duplicates

- [X] I want to request a feature or enhancement and not ask a question

### The problem

High bandwidth usage if big filter lists get updated frequently.

### Proposed solution

Compare the ETag of the local filter file with the one on the server before downloading.

### Alternatives considered and additional information

I update filters with curl now because it also uses way less RAM and IO.
Example (thx to ChatGPT):

```
#!/bin/bash

# URL of the file to download
URL="https://example.txt"

# Local file to save the downloaded content
LOCAL_FILE="/mnt/example.txt"

# File to store the ETag
ETAG_FILE="/mnt/etagexample.txt"

# Function to download the file
download_file() {
echo "Downloading file..."
curl -o "$LOCAL_FILE" -D - "$URL" | grep -i etag > "$ETAG_FILE"
}

# Check if the ETag file exists
if [ -f "$ETAG_FILE" ]; then
# Get the saved ETag
SAVED_ETAG=$(cat "$ETAG_FILE" | awk -F'"' '/etag/ {print $2}')

# Make a HEAD request to get the current ETag from the server
CURRENT_ETAG=$(curl -I "$URL" 2>/dev/null | grep -i etag | awk -F'"' '/etag/ {print $2}')

# Compare the ETags
if [ "$SAVED_ETAG" != "$CURRENT_ETAG" ]; then
echo "ETag has changed. Downloading new file..."
download_file
else
echo "ETag has not changed. No download needed."
fi
else
echo "No previous ETag found. Downloading file..."
download_file
fi
```

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.