decodeCacheControl method

void decodeCacheControl(
  1. List<String> cacheControlHeader
)

Implementation

void decodeCacheControl(List<String> cacheControlHeader) {
  final reg = RegExp(r'max-age=(\d+)', caseSensitive: false);

  cacheControlHeader.forEach((header) {
    final match = reg.firstMatch(header);
    if (match != null && match.group(0) != null) {
      try {
        var cacheAge = int.parse(match.group(0).toString().substring(8));
        if (cacheAge > 0) {
          _timeoutInSeconds = cacheAge;
        }
      } catch (e) {
      }
    }
  });
}