Just activated Varnish cache on my magento site and started receiving this error (it worked just fine when Varsnish wasn't active):

```
Fatal error: Call to a member function getImageUrl() on a non-object in /home/admin/public_html/golulo.es/app/design/frontend/golulo/default/template/page/html/page_header.phtml on line 4

```

Here is the content from `page_header.phtml`

```
<?php
    $_helper    = Mage::helper('catalog/output');
    $_category  = Mage::registry('current_category');
    $_imgUrl = $_category->getImageUrl();
?>
<?php
    if (!$_imgUrl){
?>
<script type="text/javascript">
jQuery(function($){
    $(".top-container").addClass("no-image");
});
</script>
<?php
    }
?>
<div class="category-header-container">
    <div class="bgback" style="background:#F7F6F4;">
        <div class="container row" style="<?php if($_imgUrl): ?>background-image: url(<?php echo $_imgUrl; ?>);<?php endif; ?>">
            <div class="table-container">
                <div class="category-top-title">
                    <h1><?php echo $_helper->categoryAttribute($_category, $_category->getName(), 'name') ?></h1>
                </div>
                <div class="left-area breadcrumbs-holder">
                    <?php echo $this->getChildHtml("breadcrumbs"); ?>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="zn_header_bottom_style"></div>

```

If I remove `$_imgUrl` for example, I get the same error with `getName`.

I'm trying to find any working solution, but I can't find anything that would help.

Any ideas?
Thanks,