diff --git a/client/rhel/yum-rhn-plugin/rhnplugin.py b/client/rhel/yum-rhn-plugin/rhnplugin.py
index 7e3b4cf..585228f 100644
--- a/client/rhel/yum-rhn-plugin/rhnplugin.py
+++ b/client/rhel/yum-rhn-plugin/rhnplugin.py
@@ -30,6 +30,9 @@ from up2date_client import rhnPackageInfo
 from up2date_client import up2dateErrors
 import rhn.transports
 
+import string
+import time
+
 __revision__ = "$Rev$"
 
 requires_api_version = '2.5'
@@ -41,6 +44,9 @@ COMMUNICATION_ERROR = _("There was an error communicating with RHN.")
 
 import M2Crypto.SSL.Connection
 
+from iniparse.compat import ParsingError, ConfigParser
+from yum.parser      import ConfigPreProcessor, varReplace
+
 def bypass_m2crypto_ssl_connection_check(*args, **kw):
     """This needs to return True, it's used to bypass a check in 
     M2Crypto.SSL.Connection
@@ -48,6 +54,101 @@ def bypass_m2crypto_ssl_connection_check(*args, **kw):
     return True
 
 
+rhn_repo_cache_fname = "/var/cache/yum/rhnplugin"
+rhn_repo_cache_time  = 60 * 60 * 10 # 10 minutes
+rhn_repo_cache_cdir  = "/etc/yum/spacewalk.repos.d"
+
+def _rhnp_bad_repo_id(line):
+    """ Check for bad repo. ids """
+
+    if line in ['main', 'installed']:
+        return True
+
+    # Check the repo.id against the valid chars
+    for byte in line:
+        if byte in string.ascii_letters:
+            continue
+        if byte in string.digits:
+            continue
+        if byte in "-_.:":
+            continue
+
+        return True
+    return False
+    
+def _rhnp_cached_repos():
+    """ Can we get cached RHN repo data, if so use that. """
+
+    if not os.path.exists(rhn_repo_cache_fname):
+        print "JDBG: no", rhn_repo_cache_fname
+        return None
+
+    mtime = os.stat(rhn_repo_cache_fname)[8]
+    now   = time.time()
+    if mtime > now:
+        print "JDBG: future time", rhn_repo_cache_fname
+        return None
+    if mtime + rhn_repo_cache_time < now:
+        print "JDBG: cache expire", rhn_repo_cache_fname
+        return None
+
+    ret = set()
+    for line in open(rhn_repo_cache_fname):
+        line = line.strip()
+        if not line or _rhnp_bad_repo_id(line):
+            print "JDBG: bad", rhn_repo_cache_fname
+            return None # Something bad happened, just ignore it
+        ret.add(line)
+    return ret
+
+# We end up creating two repos, which is ugly and slow ... but it works
+def _rhnp_load_cached_repo(base, repoid, cachedir, proxy_url, sslcacert, defs):
+    fname = "%s/%s.repo" % (rhn_repo_cache_cdir, repoid)
+    if not os.path.exists(fname):
+        return None
+
+    # Load a yum repo file
+    repo_age = os.stat(fname)[8]
+    confpp_obj = ConfigPreProcessor(fname, vars=base.yumvar)
+    parser = ConfigParser()
+    try:
+        parser.readfp(confpp_obj)
+    except ParsingError, e:
+        base.logger.warning(e)
+        return None
+
+    try:
+        repo = base.readRepoConfig(parser, repoid)
+    except (yum.Errors.RepoError, yum.Errors.ConfigError), e:
+        base.logger.warning(e)
+        return None
+
+    # Get the options which were set in the config. file
+    opts = set(parser.options(repoid))
+    for opt in ('name', 'baseurl', 'gpgkey'):
+        opts.remove(opt)
+
+    # Copy that data to the RHN repo object:
+    channel = {'label' : repo.id,
+               'name' : repo.name, 'url' : repo.baseurl,
+               'gpg_key_url' : ' '.join(repo.gpgkey)}
+    rhnrepo = RhnRepo(channel, repo.enabled)
+    for opt in opts:
+        setattr(rhnrepo, opt, getattr(repo, opt))
+    if 'gpgcheck' not in opts:
+        rhnrepo.gpgcheck     = defs[0]
+    if 'enablegroups' not in opts:
+        rhnrepo.enablegroups = defs[1]
+
+    rhnrepo.basecachedir = cachedir
+    rhnrepo.proxy        = proxy_url
+    rhnrepo.sslcacert    = sslcacert
+
+    # Due to above double load this isn't really "true" atm.
+    rhnrepo.repo_config_age = repo_age
+    rhnrepo.repofile        = fname
+    return rhnrepo
+
 def init_hook(conduit):
     """ 
     Plugin initialization hook. We setup the RHN channels here. 
@@ -121,6 +222,28 @@ def init_hook(conduit):
         rhn_enabled = False
         return 
 
+    repos = conduit.getRepos()
+    sslcacert = get_ssl_ca_cert(up2date_cfg)
+
+    cachedir = conduit.getConf().cachedir
+    default_gpgcheck = conduit.getConf().gpgcheck
+    gpgcheck = conduit.confBool('main', 'gpgcheck', default_gpgcheck)
+    enablegroups = conduit.getConf().enablegroups
+    defs = (gpgcheck, enablegroups)
+
+    cached_rhn_repos = _rhnp_cached_repos()
+    if cached_rhn_repos is not None:
+        print "JDBG: loading cached RHN repos"
+        for repoid in cached_rhn_repos:
+            if repoid in rhnChannel.channel_blacklist:
+                continue
+            repo = _rhnp_load_cached_repo(conduit._base, repoid, cachedir,
+                                          proxy_url, sslcacert, defs)
+            if repo is not None:
+                repos.add(repo)
+        return
+
+    print "JDBG: loading RHN repos"
     CHANNELS_DISABLED = _("RHN channel support will be disabled.")
     try:
         svrChannels = rhnChannel.getChannelDetails()
@@ -133,30 +256,62 @@ def init_hook(conduit):
             "\n" + str(e))
         return
    
-    repos = conduit.getRepos()
-    cachedir = conduit.getConf().cachedir
-    default_gpgcheck = conduit.getConf().gpgcheck
-    gpgcheck = conduit.confBool('main', 'gpgcheck', default_gpgcheck)
-    sslcacert = get_ssl_ca_cert(up2date_cfg)
-    enablegroups = conduit.getConf().enablegroups
-    repoOptions = getRHNRepoOptions(conduit)
-
     for channel in svrChannels:
         if channel['label'] not in rhnChannel.channel_blacklist \
            and channel['version']:
+            fname = "%s/%s.repo" % (rhn_repo_cache_cdir, channel['label'])
+            if os.path.exists(fname):
+                repo = _rhnp_load_cached_repo(conduit._base,
+                                              channel['label'], cachedir,
+                                              proxy_url, sslcacert, defs)
+                if repo is not None:
+                    repos.add(repo)
+                continue
+
             repo = RhnRepo(channel)
             repo.basecachedir = cachedir
             repo.gpgcheck = gpgcheck
             repo.proxy = proxy_url
             repo.sslcacert = sslcacert
             repo.enablegroups = enablegroups
-            if repoOptions:
-                for o in repoOptions:
-                    setattr(repo, o[0], o[1])
-                    conduit.info(10, "Repo '%s' setting option '%s' = '%s'" %
-                            (repo.name, o[0], o[1]))
             repos.add(repo)
 
+    # Now write the cache out:
+    try:
+        rhnp_repos_fp = open(rhn_repo_cache_fname, "wb")
+        for channel in svrChannels:
+            if channel['label'] not in rhnChannel.channel_blacklist \
+                   and channel['version']:
+                print "JDBG: writing", channel['label']
+                rhnp_repos_fp.write("%s\n" % channel['label'])
+                fname = "%s/%s.repo" % (rhn_repo_cache_cdir, channel['label'])
+                if os.path.exists(fname):
+                    continue
+                if not os.path.exists(rhn_repo_cache_cdir):
+                    os.makedirs(rhn_repo_cache_cdir)
+
+                # Create an RHN .repo file
+                last_file = fname
+                fp = open(fname, "wb")
+                url = channel['url']
+                if type(url) == list:
+                    url = ' '.join(url)
+                print "JDBG: calling write", channel['label']
+                fp.write("""\
+[%s]
+enabled      = true
+name         = %s
+baseurl      = %s
+gpgkey       = %s
+""" % (channel['label'], channel['name'], url, channel['gpg_key_url']))
+                fp.close()
+                del fp
+                last_file = None
+    except:
+        print "JDBG: FAIL cached repos write"
+        os.unlink(rhn_repo_cache_fname)
+        if last_file is not None:
+            os.unlink(last_file)
 
 #bz226151,441265
 #Allows a "yum clean all" to succeed without communicating
@@ -226,7 +381,7 @@ class RhnRepo(YumRepository):
                           'X-RHN-Auth-Server-Time',
                           'X-RHN-Auth-Expire-Offset']
     
-    def __init__(self, channel):
+    def __init__(self, channel, enabled=True):
         YumRepository.__init__(self, channel['label'])
         self.name = channel['name']
         self._callbacks_changed = False
@@ -247,8 +402,6 @@ class RhnRepo(YumRepository):
         self.retries = 1
         self.throttle = 0
         self.timeout = 60.0
-        self.metadata_cookie = 'cookie'
-        self.metadata_expire = 0
 
         self.http_caching = True
 
@@ -261,7 +414,8 @@ class RhnRepo(YumRepository):
             #TODO: Warn about this or log it
             pass
 
-        self.enable()
+        if enabled:
+            self.enable()
 
     def setupRhnHttpHeaders(self):
         """ Set up self.http_headers with needed RHN X-RHN-blah headers """
@@ -551,16 +705,3 @@ def force_http(serverurl):
     if typ not in ("http"):
         httpUrl = "http:" + uri
     return httpUrl
-
-def getRHNRepoOptions(conduit):
-    from ConfigParser import NoSectionError
-    try:
-        if conduit:
-            if hasattr(conduit, "_conf") and hasattr(conduit._conf, "items"):
-                return conduit._conf.items("repos")
-    except NoSectionError, e:
-        pass
-    return None
-
-
-
