CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-requests-cache

A persistent cache for python requests

76

1.26x
Overview
Eval results
Files

task.mdevals/scenario-5/

HTTP Cache Validator

A tool that efficiently checks for updates to web resources using conditional HTTP requests to minimize bandwidth usage.

Capabilities

Conditional request validation

The tool should fetch web resources and efficiently check for updates by validating whether content has changed before downloading the full response.

  • Fetches a URL for the first time and stores the response @test
  • On subsequent requests to the same URL, efficiently checks if the content has changed without downloading the full response when content is unchanged @test
  • Correctly retrieves the cached version when content has not changed @test
  • Updates the cache when content has been modified on the server @test

Resource monitoring

The tool should track multiple web resources and check for changes efficiently.

  • Checks multiple URLs and returns whether each has been modified since last check @test

Implementation

@generates

API

class CacheValidator:
    """
    A validator that uses HTTP caching to efficiently check for resource updates.

    This class uses persistent caching with Last-Modified validation to minimize
    bandwidth when checking if web resources have changed.
    """

    def __init__(self, cache_name: str = 'http_cache'):
        """
        Initialize the cache validator.

        Args:
            cache_name: Name of the cache database to use for storing responses
        """
        pass

    def fetch(self, url: str) -> str:
        """
        Fetch a URL, using cached version if available and not modified.

        On the first request, downloads and caches the response. On subsequent
        requests, validates if the content has changed and only downloads if modified.

        Args:
            url: The URL to fetch

        Returns:
            The response body as a string
        """
        pass

    def check_updates(self, urls: list[str]) -> dict[str, bool]:
        """
        Check multiple URLs for updates efficiently.

        Args:
            urls: List of URLs to check

        Returns:
            Dictionary mapping each URL to True if modified, False if not modified
            For URLs not yet cached, returns True (considered modified/new)
        """
        pass

Dependencies { .dependencies }

requests-cache { .dependency }

Provides HTTP caching with conditional request support for Last-Modified validation.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/pypi-requests-cache

tile.json