HttpUrlConnection with HttpResponseCache or Volley for better caching implementation in android

1.7k Views Asked by At

I am developing an app for Android in which there are a lot of http requests to server to fetch some data. My response includes a lot of images as well along with texts in JSON format.

I would like to make my application work faster using proper caching like Google Play, Google plus and other application uses.

I already know about android Volley library and tried and developed some samples to test and it is serving great and caching my images perfectly as expected . But recently while doing a research for the same on internet , I came to know about HttpResponseCache classes where you install an cache for Http request response.

Now I am bit confused with which I should go, I already tried Volley but did not tries using HttpResponseCache.

My Question is :

Are they doing the same thing internally ?

If not which will be better to go with.

You expert advice or experience will save a lot time of mine.

1

There are 1 best solutions below

4
On

I can tell about my experience. My task was the same. I had to download a lot of images and other requests. My first attemp was based on HttpUrlConnection with using HttpResponseCache. It worked, but speed of download wasn't fast enough (12kb image has been downloading about 1.5-2 seconds, this is too long). So I had to find new faster solution.
I knew about volley, but didn't know about some features in it, especially priority of downloading. And main purpose was exactly priority, so I began to create own solution. I tried to use apache HttpClient instead of HttpUrlConnection, and it was realy faster, same image has been downloading from 200 to 300 miliseonds.
I wasn't able to achieve faster speed with HttpUrlConnection, but as I'm not expert, I think that there was small mistake and HttpUrlConnection can works faster, unfortunately this question is still closed for me.
If look through the Volley source, it uses HttpUrlConnection class after API >= 9, and HttpClient class before API level 9. I didn't measure download speed with volley, so I can't say is it fast or no.
So, what conclusions I came, my solution costed me at least 3 or 4 days, and if I knew that volley have priority of download, maybe I hadn't have to write it (if it is fast too). Answering on your question, yes Volley doing the same, and if you don't need to do something special you can use Volley, it will be much faster than writing own solution.