Results 1 to 3 of 3

Thread: Dynamic CSS file

  1. #1
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    256
    Thanks
    1
    Thanked 21 Times in 21 Posts

    Default Dynamic CSS file

    So I have been reading up on how to do a dynamic css file and it's pretty easy apparently. So at this point I understand how to do it, but the question I have is about the cache issue it seems to cause according to what I have read. Have any of you used this method to make your css files and have you experienced any cache issues.

    The info I have read indicates that unless you specify a additional header type to tell the browser not to cache the css file it may not always take effect is the customer has been to the site recently. I know that the purpose of a css file is to have it cached to help eliminate the need to keep downloading the file with every new page request, so what's the downside to a dynamic css file?

    I am hoping for a real solid answer on this cause I am looking at making a CMS to market, but I want it to have a dynamic css that the client can change in the admin panel. So give me the pros and cons.

    Thanks

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    What is "dynamic CSS"? Using PHP, you can actually allow them to modify a real .css file (by opening and editing the file and saving it as a text .css file externally). But if you want that file to be dynamically generated by PHP every time it is loaded (for example, you could change the colors based on the time of day), then you would need to use a .php file and add the headers for CSS.
    It's not very difficult to do this.

    I wrote this tutorial a long time ago, but I think it may help you:
    http://www.dynamicdrive.com/forums/s...ad.php?t=21617
    The basics are there at least.

    The second part is working with caching. You don't need to research specifically how to do this with dynamic CSS files. Just look up caching in general to find the settings you'll need, just like any other .css or .htm file.


    Note that you can actually dynamically generate .css files if you tell your server to process them as PHP, but that is an extra load for every .css file and it's probably not worth it.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Apr 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Quote Originally Posted by djr33 View Post
    What is "dynamic CSS"? Using PHP, you can actually allow them to modify a real .css file (by opening and editing the file and saving it as a text .css file externally). But if you want that file to be dynamically generated by PHP every time it is loaded (for example, you could change the colors based on the time of day), then you would need to use a .php file and add the headers for CSS.
    It's not very difficult to do this.

    I wrote this tutorial a long time ago, but I think it may help you:
    http://www.dynamicdrive.com/forums/s...ad.php?t=21617
    The basics are there at least.

    The second part is working with caching. You don't need to research specifically how to do this with dynamic CSS files. Just look up caching in general to find the settings you'll need, just like any other .css or .htm file.


    Note that you can actually dynamically generate .css files if you tell your server to process them as PHP, but that is an extra load for every .css file and it's probably not worth it.
    thank you . its really a great tutorial i was trying to learn.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •