Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set cache_expiration_time when storing data to cache
When we switched to PSR-16 inspired `DataCache` in bb38d74, we introduced a regression due to impedance mismatch between PSR-16 and HTTP Caching mechanisms: - HTTP caching uses two step invalidation – if a cache entry is accessed after its TTL passes, a request is made with a stored HTTP caching header (e.g. ETag) and the cache is considered invalid only if the server returns something else than 304 Not Modified response. - On the other hand, PSR-16 cache does not allow access to entries past its TTL, forcing us to fetch the content every time, even when the remote server could tell us it is still fine. To work around this, bb38d74 decided to store `cache_expiration_time` field in the cache entry so that we could bypass the PSR-16’s strict TTL and handle expiration ourselves. But there were few places where we forgot to set it. This patch fixes that. Unfortunately, because we also pass the same value as `cache_expiration_time` to `DataCache::set_data` as TTL, the early eviction still happens. We will also need to set the TTL to `null` (unlimited) so that the `DataCache` does not evict the entries behind our back. Partly fixes simplepie#830 ([BUG] Cache constantly updating)
- Loading branch information