Comments (6)
Your testing is very different from what would be experienced in the real world.
In the real world:
- storage read/write access may be slow (compared to "normal" computing standards), but it's still faster than the emulator.
- Mobile devices have unreliable network access. So if you can cache something locally, you don't need to use the network at all - so the user won't see an error if the network is down - the app continues to work.
- Mobile network access is slow - I bet that the incredibly slow mobile network is slower than the storage, so caching wins.
- Mobile network access is metered - so using less bandwidth means the user doesn't hit their limit as fast, making them happier users of your app.
With that said, I'd be really psyched if you looked through the code and took a look at ways to make it faster. Even if you just submit ideas, that would be pretty great - a patch / merge request would be even better.
from httpresponsecache.
I just integrated the cache into my app, which serially pulls down about 20 images at launch (while showing a splash screen) before allowing the user to do anything and stores them in an in-memory cache. I then tested performance on a Samsung Galaxy Nexus using both the built-in ICS HttpResponseCache and your port. The performance was roughly the same between the two; if anything your port performed a little better. But that's the good news. The bad news:
- Time to load with no HttpResponseCache installed: ~7 sec
- Time to load with HttpResponseCache installed and populated: ~1 sec
- Time to load with HttpResponseCache installed but empty: ~33 sec
Is this huge disparity between "empty cache" and "no cache at all" merely caused by the general slowness of writing to internal storage? Or is something else going on?
It is not, at least, an issue with your port per se since the ICS-provided HttpResponseCache also exhibits the poor behavior. Maybe what's needed is some delayed write functionality so the caller doesn't have to wait for the requested data to be fully cached before it's made available to him?
from httpresponsecache.
If you turn on StrictMode, you will see violation for HttpResponseCache installed. It will be very wise to put HttpResponseCache installed under AsyncTask.
from httpresponsecache.
I started my timing at the point when I began loading the images, not when I installed the cache.
Is the install process maybe "lazy", i.e. it only does the work when you first use a HttpURLConnection that has caching turned on?
from httpresponsecache.
Applying the patch in issue #9 solved the performance issues I described above. What it implies, however, that app developers should prefer to use candrews's HttpResponseCache even on ICS since the stock version that ships with ICS doesn't have the patch to fix the unreasonably slow performance when writing to cache.
from httpresponsecache.
I added a note to the README.md that this library may be a later version that one included in Android on the target, so developer may want to use it unconditionally. See 59e8ed9
from httpresponsecache.
Related Issues (20)
- Cache size surpassing limit HOT 1
- setDefaultHostnameVerifier in install()
- java.lang.NoSuchMethodError: Llibcore/net/http/HttpResponseCache.getCache HOT 3
- Add support for non-shared cache? HOT 4
- Allow pages not ending in newline HOT 3
- gzip Header disappers after a requests with "max-age=0"
- Ability to override uriToKey?
- Responses are not cached HOT 2
- Data not cached when gzip content-encoding is combined with chunked transfer-encoding. HOT 5
- Not respecting max-age: 0 for Cache-Control HOT 1
- NameConstraints use incorrect signature
- java.net.SocketException: sendto failed: EPIPE (Broken pipe)
- DiskLruCache version dependency out of date...
- com.integralblue.httpresponsecache.compat.libcore.net.http.ResponseHeaders.chooseResponseSource(long, RequestHeaders) does not honor only-if-cached cache control directive
- Cache not updated
- incorrect content-length causes problems on ssl connection HOT 1
- PUT request method are not caching HOT 1
- How to avoid installing and closing 'HttpResponseCache' on every Activity and Service?
- can it work with volley? HOT 1
- POST method request throws ProtocolException("POST does not support writing") when use it in Java
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 httpresponsecache.