Skip to content

Commit cbb7306

Browse files
Caching moved to CDN (#76)
* Add GCS proxy endpoint for serving report files and MIME type mapping * Add IAM member for service account storage object viewer in Google Cloud Storage * chore: update @google-cloud/functions-framework dependency to allow minor version upgrades * format Terraform * feat: add CDN controller and update API paths for versions and reports * Apply suggestion from @Copilot Co-authored-by: Copilot <[email protected]> * feat: update GCS proxy endpoint to serve static files instead of reports * feat: remove unused IAM member for storage object viewer * feat: add tests for static file retrieval and error handling in API routes * feat: update API routes to serve static files instead of reports * feat: update API routes and MIME type handling for static files * feat: remove cache management endpoints and related tests from API * feat: update Node.js version requirement in README * Update src/__tests__/routes.test.js Co-authored-by: Copilot <[email protected]> * Update src/__tests__/routes.test.js Co-authored-by: Copilot <[email protected]> * fix --------- Co-authored-by: Copilot <[email protected]>
1 parent 686e4e9 commit cbb7306

File tree

9 files changed

+288
-369
lines changed

9 files changed

+288
-369
lines changed

README.md

Lines changed: 1 addition & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This is an HTTP Archive Reporting API that provides reporting data via various e
66

77
### Prerequisites
88

9-
- Node.js 18+
9+
- Node.js 22+
1010
- npm
1111
- Google Cloud account with necessary permissions
1212
- Set environment variables:
@@ -30,7 +30,6 @@ The API will be available at <http://localhost:3000>
3030
- **Cache Headers**: 6-hour cache control for static data
3131
- **Health Check**: GET `/` returns health status
3232
- **RESTful API**: All endpoints follow REST conventions
33-
- **Backend caching**: Some responses are cached on the backend for 1 hours to improve latency
3433

3534
### `GET /`
3635

@@ -501,51 +500,6 @@ Returns a JSON object with the following schema:
501500
]
502501
```
503502
504-
### `GET /cache-stats`
505-
506-
Provides statistics about the API's cache.
507-
508-
```bash
509-
curl --request GET \
510-
--url 'https://{{HOST}}/v1/cache-stats'
511-
```
512-
513-
Returns a JSON object with the following schema:
514-
515-
```json
516-
{
517-
"cache_hits": 12345,
518-
"cache_misses": 6789,
519-
"last_cleared": "2023-10-01T12:00:00Z"
520-
}
521-
```
522-
523-
### `POST /v1/cache-reset`
524-
525-
Resets all caches in the API. This endpoint requires a POST request.
526-
527-
```bash
528-
curl --request POST \
529-
--url 'https://{{HOST}}/v1/cache-reset'
530-
```
531-
532-
Returns a JSON object with the following schema:
533-
534-
```json
535-
{
536-
"success": true,
537-
"message": "All caches have been reset",
538-
"before": {
539-
"queryCache": 150,
540-
"dateCache": 12
541-
},
542-
"after": {
543-
"queryCache": 0,
544-
"dateCache": 0
545-
}
546-
}
547-
```
548-
549503
## Testing
550504
551505
```bash
@@ -667,34 +621,4 @@ Response:
667621
}
668622
```
669623
670-
## Cache Stats Private Endpoint
671-
672-
The Cache Stats private endpoint provides information about the API's cache performance, including cache hits, misses, and the last time the cache was cleared. This endpoint is useful for monitoring and debugging cache behavior.
673-
674-
```bash
675-
curl "https://tech-report-api-dev-226352634162.us-central1.run.app/v1/cache-stats" \
676-
-H "Authorization: bearer $(gcloud auth print-identity-token)"
677-
```
678-
679-
Returns a JSON object with the following schema:
680624
681-
```json
682-
{
683-
"queryCache": {
684-
"total": 3220,
685-
"valid": 2437,
686-
"expired": 783,
687-
"ttl": 3600000
688-
},
689-
"dateCache": {
690-
"total": 4,
691-
"valid": 4,
692-
"expired": 0,
693-
"ttl": 3600000
694-
},
695-
"config": {
696-
"maxCacheSize": 5000,
697-
"cleanupStrategy": "size-based-lru"
698-
}
699-
}
700-
```

0 commit comments

Comments
 (0)