basic

command
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2025 License: MIT Imports: 5 Imported by: 0

README

Basic Example

This example demonstrates the basic usage of httpcache with in-memory caching.

Features Demonstrated

  • Creating an HTTP client with in-memory cache
  • Making cacheable requests
  • Verifying cache hits with X-From-Cache header
  • ETag-based cache validation

Running the Example

From the project root directory:

go run ./examples/basic/main.go

Or from the examples/basic directory:

go run main.go

Expected Output

The first request will fetch from the server, and the second request will be served from the cache. You'll see the X-From-Cache: 1 header on cached responses.

Key Points

  • The in-memory cache is fast but not persistent
  • Responses are cached according to HTTP caching headers
  • The cache automatically handles ETag and Last-Modified validation
  • No configuration needed - works out of the box

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL