Forum Moderators: open

Message Too Old, No Replies

Will browsers still cache this file?

         

benj0323

1:39 am on Nov 17, 2004 (gmt 0)

10+ Year Member



I use a template system on my website and as a result all of my frontend code is stored in a database. So in order to use CSS or JavaScript in my webpages I just have to echo it out from the database. Well the disadvantage to this is that it doesnt cache the css or javascript because its hardcoded into the html file. Well I did this:

<link rel="stylesheet" type="text/css" href="global.php?template=global_css&amp;ext=css" media="all" />

<script type="text/javascript" src="global.php?template=global_javascript&amp;ext=js"></script>

Will browsers still cache the css and javascript code even though its not a file, its just echoing out from the database? Also, I change the mime-type before echoing it out, so its text/css or whatever it needs to be.

Thanks a lot for your help.

jetboy_70

1:57 am on Nov 17, 2004 (gmt 0)

10+ Year Member



No. The files will be sent as PHP, which means no caching information is going to be sent to the browser. However, take a look at Span's link on this thread:

[webmasterworld.com ]

If you send an appropriate Cache-Control header using the same PHP code you used to set text/css you should be able to get things to cache.

benj0323

8:25 am on Nov 17, 2004 (gmt 0)

10+ Year Member



Thanks for the help.