Results 1 to 10 of 10

Thread: cache only for 8 hours

  1. #1
    Join Date
    Jul 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default cache only for 8 hours

    bs"d

    Hello

    I want that the brower will cache my site only for 8 hours
    so if someone get in tommorow the page will load from the server and not from the cache...

    for that I'll use: <META HTTP-EQUIV="EXPIRES" CONTENT=mon, 27 sep 2010 14:30:00 GMT>

    As you understand I need that the date in the tag will be dynamically...
    but for that I need a script that I don't know to write... or to find one in the internet..

    can someone plzz help me?

    thanks
    yitschak

  2. #2
    Join Date
    Jul 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    This messege is only to subscribe the messege for me...

    ignore it

    sorry =]

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    You can use PHP and the function date() to generate this. Do you have PHP available?
    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

  4. #4
    Join Date
    Jul 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default I'm not sure

    All I know that this is a Microsoft Server..
    and I was told that the server that I'm using not supporting PHP

    But I wanna check this...
    can you write me some code that I can use to check if PHP is supported?

    thx
    yitschak

  5. #5
    Join Date
    Jul 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I guess PHP is not supported, because I put a file named phpinfo.php on my server
    which contained the next code:

    <?php
    phpinfo();
    ?>

    and I got an Error: "The page cannot be found"

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    You shouldn't get a 404 ("not found") error for a PHP file on a server that doesn't support PHP. Instead, it should show up blank, show up as html (so you read "<?.....") or download as a file-- this probably all depends on the browser. So maybe you typed the wrong URL? Maybe PHP does work...
    It's possible that your server is configured to ignore .php, but that's a very odd behavior...

    If it's a microsoft server it's likely that you do not have PHP, but it's also likely that you do have ASP, microsoft's serverside language that does basically the same thing. Personally I use PHP, but there's no reason you can't use ASP in the same way-- I can't tell you the specifics though. It shouldn't be hard if you search for "ASP date".
    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

  7. #7
    Join Date
    Jul 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Thx

    This information is very helpful...

    but, do I really have to change the extention of all the pages in my site to aspx just for one-line script?

    is there another way?

    thanks! =]

  8. #8
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    By default, .htm and .html are processed as HTML. So, yes, you will need to do something to change them to .php or .asp, or whatever other language you want to use if it isn't just HTML.

    There are, however, a few different ways you can approach this:

    1. You can manually rename all files. While this sounds like it's a lot of work, it will make everything simpler in the end. Remember this also means you need to change all hrefs that link to these pages. (It's possible to automate this process by running a script that automatically converts .htm to .php if you want, but planning that and executing it can take longer than just doing it manually.)

    2. You can tell your server to treat .htm as PHP file. Basically this is just a different setting than the default and it will pretend that ".htm" means PHP. This is very easy, done through .htaccess, but it is a weird way to fix the problem: .htm is NOT PHP, so why are you telling your server to treat it like it is? There are two main reasons not to do this: 1) it means that ALL .htm files will be run as .php (less efficient); 2) it will be confusing for later updates: why are the .htm files magically running PHP code? It's unexpected.

    3. You could use mod_rewrite (.htaccess) to automatically switch all (or some) .htm extensions to .php. This wouldn't fix all of the issues with it, so you would still need to rename all of your files. But this would mean that links to ".htm" would 1) appear to the user as .htm still (even though the server is using a .php page) and 2) the old .htm links would not be broken, so it would save you time changing all pages that link to the updated pages, just not the time changing the extensions. I don't really recommend this approach, but it would be helpful.... mostly it's just a lot of work and confusing...
    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

  9. #9
    Join Date
    Jul 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default thx!! =]

    I guess I'll do the manual change...

    Good day!!
    and Thx!! =]

  10. #10
    Join Date
    Jul 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default didn't finished yet

    I wrote the next code:

    <script type="text/vbscript">//<![CDATA[
    <!--
    dim dateNow
    dim str
    dim daysOfWeek(6)
    daysOfWeek(0)="Sun"
    daysOfWeek(1)="Mon"
    daysOfWeek(2)="Tue"
    daysOfWeek(3)="Wed"
    daysOfWeek(4)="Thu"
    daysOfWeek(5)="Fri"
    daysOfWeek(6)="Sat"
    dim monthsNames(11)
    monthsNames(0)="Jan"
    monthsNames(1)="Feb"
    monthsNames(2)="Mar"
    monthsNames(3)="Apr"
    monthsNames(4)="May"
    monthsNames(5)="Jun"
    monthsNames(6)="Jul"
    monthsNames(7)="Aug"
    monthsNames(8)="Sep"
    monthsNames(9)="Oct"
    monthsNames(10)="Nov"
    monthsNames(11)="Dec"
    dateNow=dateadd("h", -1, Now) //1 hour forward because I took 2 hours back for GMT
    dim dayOfMonth
    dayOfMonth=CStr(Day(dateNow))
    if Len(dayOfMonth)=1 Then dayOfMonth="0"+dayOfMonth

    str=CStr(daysOfWeek(Weekday(dateNow)))+", "+dayOfMonth+" "+monthsNames(Month(dateNow))+" "+CStr(Year(dateNow))+" "+CStr(Time)+" GMT"
    document.write("<META HTTP-EQUIV=""EXPIRES"" CONTENT="+str+">")
    -->
    //]]></script>


    When I checked the cache there was no expiration date...
    but, I guess the script is ok...

    because even when I wrote the meta tag manually for now to check if it works it didn't show any expiration date....

    so I guess somthing wrong with the meta atg and not in the script

    good day

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
  •