iMac Internet Surfing Issue
Check your network connection. 


Open System Preferences
Click on Network, on the button Assist me... and then on diagnostics.
Choose your Network e.g. LAN and check the connection.


If you have at this point no problems


Click on the Network Window on the button Options.. and to the DNS Register. 
Check if any other DNS entries are there unless the standard entries from your Router.
If additional entries you can delete them if you click on the minus (-) button below.


Check if the problem exists.

If you have any Network Software or (bad Antivirus) on your mac, please disable temporary.

Clear the System Caches in that order...


Restart your mac and hold down the shift-Key during startup.
This will start in the Safe Mode. You no need to login, after the startup is done, you can restart your mac.
During startup hit the buttons Command + ALT (Option) + R to boot into internet Recovery.
Choose from there Disk Utility, check and repair the permissions of your System drive.
Restart in normal Mode and check if the problem exists.