Skip to content

A Flutter package offering multiple ways to cache responses obtained from web requests.

License

Notifications You must be signed in to change notification settings

Schloool/web-response-cache-flutter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

This package is used for caching responses obtained from web requests. There are no limitations in which representations (such as JSON, HTML, XML, ...) are cached. All major HTTP verbs such as GET, POST, PUT and DELETE are supported.

The cache will be used whenever

  • the given cache type is still in charge of being used (like when the duration of a time cache has not been reached)
  • a new request did not respond with a successful result

It is currently planned to extend the package with more cache types as well as more cache-related fields in the future. Feel free to send ideas and feedback using the GitHub Issue Board.

Example

Using a simple time cache for a JSON response:

const testUrl = 'http://worldtimeapi.org/api/timezone/Europe/Berlin';
final cachedRequest = CachedWebRequest(url: testUrl, webCacheType: TimeWebCacheType(cacheDuration: const Duration(days: 1)));
var response = await cachedRequest.startRequest();
...

// response body will have the same body content for the duration of one day
response = await cachedRequest.startRequest();

Dependencies

  • http (used for sending HTTP requests)
  • path_provider (used for getting the temporary cache directory)

Contributing

Contributions to the GitHub Repository are very welcomed. I also appreciate feature requests as well as bug reports using the GitHub Issue Board.

About

A Flutter package offering multiple ways to cache responses obtained from web requests.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages