Forum Moderators: open

Message Too Old, No Replies

Caching a file on the client-side

         

windspinner

1:48 am on Dec 12, 2006 (gmt 0)

10+ Year Member



I have a web application that generates a dropdown menu (brainjar menu) based on the permissions of a given user. As a part of the login process, a menu is created for the user, which is then saved on the server. This file is then included by any file that needs it. The content of that menu does not change anyway, so now I was wondering if there is anyway of caching it on the client's side (just like css and javascript, cached on the client's side) so that I won't be including it time and again.

Is there anyway to do it?

stajer

11:35 pm on Dec 12, 2006 (gmt 0)

10+ Year Member



You didn't mention how the menu is written (css, javascript, etc), but you might try to write it into your standard .css or .js file - a browser will cache those types of files and not update them unless it finds a change.

windspinner

5:58 am on Dec 13, 2006 (gmt 0)

10+ Year Member



The menu is in html. Can that be cached?

penders

5:02 pm on Dec 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Although your page is dynamically created on the server, you may find that the resulting page is already being cached locally by the browser.

To specifically cache the menu locally, I would have thought you would need to include it just as you would a JS file and write out the menu using JS (into a DIV or something) when the page loads - the downside of this however, is that Search Engines won't spider your menu, which may not matter if the menu is only generated once a user has logged in... but perhaps more importantly, if JS is disabled in the browser then your menu won't show.

Can you include an HTML file with the OBJECT tag...?

stajer

5:07 pm on Dec 13, 2006 (gmt 0)

10+ Year Member



An iframe might work. But, I think you will be impeding the user experience too much. Considering rewriting your menu in js and do a .js include.