Comments (2)
This complies to the HTTP spec. To prevent from clock skewing, HTTP client must not use their own clock to compute expiration but server's by using the Date response header. If a server doesn't provide a Date response header, response should be considered as uncacheable.
By the way, SDURLCache is no longer necessary as iOS 5+ implemented disk cacking.
from sdurlcache.
Agreed, but you still need some code if you want to do cache introspection. "HTTP client must not use their own clock to compute expiration but server's by using the Date response header" I agree, but isn't the code in question doing what you said it should not?
// Date is read from cached response as yesterday at 8am
NSTimeInterval expirationInterval = 0;
NSDate *expirationDate = [NSURLCache dateFromHttpDateString:expires];
// expires is today at 8am
if (expirationDate)
{
expirationInterval = [expirationDate timeIntervalSinceDate:date];
}
// time interval is 24 hours
if (expirationInterval > 0)
{
// Convert remote expiration date to local expiration date
return [NSDate dateWithTimeIntervalSinceNow:expirationInterval];
// Return now + 24 hours, calculated using client's clock
}
else
from sdurlcache.
Related Issues (20)
- XCode 4.3.1 warning HOT 2
- diskCapacity is changing
- ETags support ? HOT 1
- Etags override Cache-Control headers? HOT 1
- SDURLCache and NSURLRequestReturnCacheDataDontLoad HOT 1
- Why not save the expire-date? HOT 1
- UIWebView caching failure for iOS>5.0 HOT 5
- Where is cache in ios5.1.1?
- How to use Application Caches? HOT 3
- SDURLCache differs from the usual cache when used with UIWebView HOT 6
- Are you sure the on-disk cache was removed? HOT 1
- Suggest init diskCacheInfo on mainthread
- AFNetworking's AFImageRequestOperation cannot find cached images sometimes HOT 1
- Static Analyzer Warning - "Null pointer passed as an argument to a 'nonnull' parameter" HOT 1
- Add a new Tag to include ignoreMemoryOnlyStoragePolicy
- Warning
- not work in iOS9 HOT 2
- [SDCachedURLResponse _CFCachedURLResponse]: unrecognized selector sent to instance 0x280081d40'
- ะพ
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdurlcache.