Geri Langlois
Geri Langlois

Reputation: 686

What is the best way to cache a menu system locally, in the browser?

I have a very large cascading menu system with over 300 items in it. (I know it's large but it's a requirement.)
Currently, it's written in javascript so the external file is cached by browsers.

To improve search engine results I need to convert this to a css menu system.
I realize the browsers will also cache external stylesheets but,

If I use javascript (document.write) to write the content I could have this in an external javascript file, which would be cached locally, but,

What is the best solution?

Upvotes: 3

Views: 607

Answers (3)

David L Morris
David L Morris

Reputation: 1513

You could do the whole thing in CSS and HTML only, and you don't need yo use any Java script. See < http://www.netwiz.com.au/cssmenu.htmlvalue >. This pages shows a tool to be used with a specific documentation software, but the sample CSS and HTML shows how to use ul li elements for a CSS/HTML only menu in a large number of browsers.

You still have the problem of 300 items in the menu which will add to the loading time. If this is an issue I guess you could move this code to a separate iframe to increase the chance of it being cached at a proxy (or by the browser). At the risk of offending the purists even a frame might do the job, but you will have problems with the topic pages not being able to display the menu if they are linked to directly.

Upvotes: 0

Garo Yeriazarian
Garo Yeriazarian

Reputation: 2533

You could generate the menus beforehand into static html / javascript files, and have all the pages pull the site from the same URL on your site. That way, the client side browser will do the caching. You'll just have to have a step in your deployment that generates the html files for the menu.

Try to have it generate as much plain HTML (+JS +CSS) as possible, then whatever has to be dynamic can be adjusted with javascript.

Upvotes: 0

Dale Ragan
Dale Ragan

Reputation: 18270

The best way to accomplish what you want to do is using SiteMaps to inform Google about the urls for your web site. Basically you will want to translate your hierarchial data for the menus into a SiteMap.

Upvotes: 6

Related Questions