Problem with Varnish(2.1). Drupal’s pages aren’t cached by varnish.

I had a problem with varnish, trying to boost a drupal site by caching it. I noticed that while js, css and image files were getting cached, no other page could be cached by varnish and on each request the apache was asked to fetch the page.

That was not acceptable since the site isn’t updated really often. I found out that the reason why varnish didn’t cache is drupal’s (v7) file:
/var/www/drupal/includes/bootstrap.inc , line 1283

  'Expires' => 'Sun, 19 Nov 1978 05:00:00 GMT',

I didn’t want to just comment it out in the file, since a lot more problems could be faced regarding drupal and varnish and caching and updating drupal core later on etc.

A solution was to add the following lines in the varnish config file vcl_fetch :

if(beresp.http.Content-Type ~ "text/html") {
        set beresp.ttl = 1d;
    }

So now all pages are cached for 1 day and then the cache gets updated again when someone requests a page.

Cheers.

PS 1: I followed the instructions at https://drupal.org/node/1054886 and the documentation of varnish.
PS 2: A nice command to check if any page is requested from apache and is not in varnish cache is this:

varnishtop -b -i txurl