CSS, JQuery, PHP and Caching: What are the best practices for creating dynamic CSS with JQuery and PHP? Examples inside.
I'm using PHP to dynamically create links and their associated CSS. I'm doing it dynamically because the number and positioning of these links is dependent on the selected month.
PHP inserts these CSS declarations into the HEAD tag. This seems to work fine on Firefox, but IE apparently caches the HEAD tag. This is a problem when navigating to pages for other months since the number of days will change.
Since I'm also using JQuery for the first time in this project, I wonder if I wouldn't be better off setting the CSS with that, rather than with PHP. The problem with this would be that I'm now mixing math and functions between the PHP sections of the site and the javascript sections. Is there a better way?
An example can be
seen here. Source code for the same is
available here.
The hover links over each day in each graph are created with a PHP loop based on the number of days in the month. The CSS to position them properly above each day is also created with a PHP loop.
The problem arises if a user selects an old month with a different number of days. Since IE caches the head tag the user only sees 20 day hover links, rather than 30 or 31.
Online documentation, tutorials or book references are very much welcome. Also, if I'm just completely going in the wrong direction please let me know.
So assuming you see the page change, you can be sure the browser also got the changes in the HEAD element. However, if you're doing some Ajax tricks to stick new content on the page without refreshing it as a whole, then you are correct that the browser isn't going to update the HEAD element. I think we may need a little more detail about what you're doing.
posted by letourneau at 10:29 AM on August 20, 2008