7

Whenever I go back or forward in the Safari navigation history, it reloads the pages even when I just visited the page two seconds ago.

When navigating using back/forward buttons or swiping back and forth, the app always reloads the page from the internet.

Can I change anything to make Safari cache the pages I just visited more aggressively?

  • 1
    By default, yes Safari caches pages. When you say it reloads the pages, what do you mean exactly? Are you positive that all of the data is being retrieved from the internet again? It's possible what you view as reloading may simply be the browser re-drawing the page. – tubedogg Aug 24 '13 at 2:19
  • 1
    @tubedogg The blue progress bar in the URL box shows the progress as it downloads the page again. If I turn off the wifi, just to test that it is downloading again, it shows a blank page instead of the content, because it couldn't download the content again, and the tab title changes to "problems with the page". – Tulains Córdova Aug 24 '13 at 2:26
6

The answer is no, Safari doesn't cache pages - it does however cache elements that make up a page when the rules that the web server associates with each element allows caching.

You can see this on your specific pages by turning on the Develop menu in Safari Preferences:

enter image description here

As you can see from this picture, the page where your question is posted allows many items to be cached and the load time for those elements is in the 0.1-0.3ms range. The items that are not cached have longer load durations so perhaps the pages you are navigating either have few items with cache enabled or the overall page load time is dominated by non-cached layout and content.

If you want to cache content for offline reading, use the Reading List feature to store the page for offline use. That does more aggressively cache much of the most pages to allow reading of the page while totally offline at a later date. In your case, when Safari is online, it will check to see that the reading list version of the page is current, so it might not be exactly what you are seeking.

  • 1
    I don't want to read off-line, it's just that it bothers me that Safari reloads a page I just visited. – Tulains Córdova Aug 24 '13 at 2:44
  • 1
    Certainly don't use reading list if it's not what you want - I was hoping an explanation of how caching works in Safari might help you nonetheless. – bmike Aug 24 '13 at 2:48
5

Option 1: Incompatibility with Safari Extensions

Do you have any extensions in Safari?

I was personally having this problem too. To fix this, I disabled all my extensions and it tuned out that AdBlock was causing this for me. I have it disabled now and it doesn't reload when going back anymore.

For others who have no extensions:

Option 2: Adding NoPageCache

From an Apple Discussion Page:

  1. I downloaded NoPageCache from here
  2. I closed Safari and reopened it.
  3. I tried the app and it was still reloading pages.
  4. I disabled and removed from safari the app (preferences/extensions)
  5. Surprisingly it's not reloading anymore pages

Resources

Apple Discussion Page

Many forums such as this one reveal that this is a bug in Mountain Lion. Many people have filed complaints but Apple has yet to do anything.

4

The blue progress bar is a combination of contacting the server, downloading data, and drawing (rendering) the page in the window. If you click back, depending on your connection speed, connection lag, system speed and a bunch of other factors (how much is happening in the background, how much free RAM you have, etc) it may take a bit for the page to reload in the window, but this does not necessarily mean it is re-downloading all data.

Disabling WiFi (or any internet connection) and trying to go to a URL will ALWAYS fail, because it can't perform the initial steps to determine what page to load (cannot connect to the DNS server). Whether or not Safari ultimately downloads the page again, it will always connect to the website server first to determine if the page changed since the last visit.

You can test if Safari is caching by following these steps:

  1. Go to Safari menu > Preferences.
  2. Click on the Advanced tab.
  3. Check the box for "Show Develop menu in menu bar".
  4. Close the Preferences window.
  5. Load this wepage: http://trakt.tv/user/tubedogg. Once it is fully loaded, click Reload the current page in the Address Bar.
  6. Press ++I to enable the Web Inspector.
  7. Press control+1 to show the Resources tab.
  8. Click the disclosure triangle next to Images.
  9. In the right-hand window, review the Request & Response section. (You may have to scroll down to see it.) Check to see if Cached says Yes or No.

Safari Web Inspector with Request & Response highlighted

Note that not all images may be cached, depending on the instructions from the server. For example, some ads will tell your browser not to cache them. But if you review many or all of the images on the page, most of them should say Yes for Cached. This will determine whether or not Safari is caching correctly.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .