Skip to content

Commit 921958e

Browse files
docs
1 parent e2f503d commit 921958e

1 file changed

Lines changed: 45 additions & 6 deletions

File tree

README.md

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
# sqlite-http-cache
22
SQLite Extension to cache HTTP requests
33

4-
## Compiling
4+
and an [SQLite http proxy cache](#sqlite-proxy-cache).
5+
6+
## Installation
7+
8+
Download **httpcache** extension from the [releases page](https://github.com/walterwanderley/sqlite-http-cache/releases).
9+
10+
### Compiling from source
511

612
```sh
713
go build -ldflags="-s -w" -buildmode=c-shared -o httpcache.so
@@ -37,6 +43,19 @@ cache_expired_ttl(header, request_time, response_time, false, 3600) AS expiredTT
3743
FROM http_response;
3844
```
3945

46+
All HTTP responses are stored in tables using the following schema:
47+
48+
```sql
49+
CREATE TABLE IF NOT EXISTS http_response(
50+
url TEXT PRIMARY KEY,
51+
status INTEGER,
52+
body BLOB,
53+
header JSONB,
54+
request_time DATETIME,
55+
response_time DATETIME
56+
)
57+
```
58+
4059
## Configuring
4160

4261
You can configure the behaviour by passing parameters to a VIRTUAL TABLE.
@@ -97,7 +116,7 @@ To schedule inserts in SQLite, a common approach involves using external schedul
97116

98117
### sqlite-http-refresh
99118

100-
1. Install
119+
1. Install from source or download from [releases page](https://github.com/walterwanderley/sqlite-http-cache/releases)
101120

102121
```sh
103122
go install github.com/walterwanderley/cmd/sqlite-http-refresh@latest
@@ -122,11 +141,31 @@ WHERE unixepoch() - unixepoch(response_time) > :ttl ;
122141
```
123142
*ttl is Time to Live in seconds*
124143

144+
## SQLite Proxy Cache
145+
146+
The sqlite-http-proxy is an HTTP proxy cache that can store data in multiple sqlite databases and query concurrently to get the faster response. The cache imlements the RFC9111 (except the vary header).
125147

126-
### Programming Language Libraries
148+
1. Installation:
127149

128-
- **Python:** Libraries like schedule, APScheduler, or Celery can be used to define and manage scheduled tasks within a Python application. This application would then execute INSERT statements into your SQLite database at the specified times.
150+
Download sqlite-http-proxy from the [releases page](https://github.com/walterwanderley/sqlite-http-cache/releases), or install from source:
129151

130-
- **Node.js:** Libraries such as node-cron or agenda provide similar scheduling capabilities for Node.js applications.
152+
```sh
153+
go install github.com/walterwanderley/cmd/sqlite-http-proxy@latest
154+
```
131155

132-
- **Golang:** [Check an example](https://github.com/walterwanderley/sqlite-http-cache/blob/main/cmd/sqlite-http-refresh/main.go) using the stdlib.
156+
2. Executing:
157+
158+
```sh
159+
sqlite-http-proxy --port 9090 --response-table http_response proxy1.db proxy2.db proxy3.db
160+
```
161+
162+
3. Testing:
163+
164+
```sh
165+
time curl -x http://127.0.0.1:9090 http://swapi.tech/api/films/1
166+
time curl -x http://127.0.0.1:9090 http://swapi.tech/api/films/1
167+
```
168+
169+
```sh
170+
sqlite-http-proxy --help
171+
```

0 commit comments

Comments
 (0)