Jump to content

afshin.m

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Posts posted by afshin.m

  1. Hi,

     

    i want to set a custom (and empty) 404 error for my static contents like CSS, Gif, Jpeg etc.

    i found this code :

     

    <FilesMatch "\.(css|png|jpg|jpeg|gif|bmp|swf|flv)$">
       ErrorDocument 404 error-404.txt
    </FilesMatch>

     

    But it not worked for images that located in sub folders, it works for images that located in the root folder and where my .htaccess file located.

     

    Please help, thanks

  2. Hi,

     

    I use this headers for my PHP file:

            header("Last-Modified: " . gmdate("D, d M Y H:i:s",filemtime("../cache/css/".$md5file.".css")) . " GMT");
    header("Expires: " . gmdate("D, d M Y H:i:s", time()+(2592000)) . " GMT");
    header('Cache-Control: public, max-age=2592000');
    

     

    But when i check my website in FireBug, i get 200 OK response but i think this is should response 304 Not modified ...?

     

    See this details :

     

    [b]Response Header[/b]
    
    Date	Sat, 05 Jun 2010 07:04:53 GMT
    Server	Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.12 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1
    X-Powered-By	PHP/5.3.1
    Last-Modified	Wed, 28 May 2008 21:02:26 GMT
    Expires	Mon, 05 Jul 2010 07:04:53 GMT
    Cache-Control	public, max-age=2592000
    Content-Encoding	gzip
    Vary	Accept-Encoding
    Content-Length	408
    Keep-Alive	timeout=5, max=99
    Connection	Keep-Alive
    Content-Type	text/css
    
    [b]Request Headers[/b]
    
    Host	localhost
    User-Agent	Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
    Accept	text/css,*/*;q=0.1
    Accept-Language	en-us,en;q=0.5
    Accept-Encoding	gzip,deflate
    Accept-Charset	ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive	115
    Connection	keep-alive
    Referer	http://localhost/cache/test.php
    Cookie	PHPSESSID=fnrlds14pqedj0s96mvasfqvo5
    If-Modified-Since	Wed, 28 May 2008 21:02:26 GMT
    Cache-Control	max-age=0

     

    And more about cache:

     

    Last Modified	Sat Jun 05 2010 10:34:53 GMT+0330 (Iran Standard Time)
    Last Fetched	Sat Jun 05 2010 10:34:53 GMT+0330 (Iran Standard Time)
    Expires	Mon Jul 05 2010 10:34:53 GMT+0330 (Iran Standard Time)
    Data Size	408
    Fetch Count	23
    Device	disk

     

    Is there any solution?  ::)

    Thanks.

  3. Thanks, good

     

    Now i check a website with my caching system and also enable YSlow...

    I get this errors:

     

    Grade F on Add Expires headers
    
    There are 93 static components without a far-future expiration date.
    
        * (no expires) http://localhost/cache/test_files/mod_thumbsup.css
    ...
    

     

    I think this is because i redirect all images/js/css with .htaccess to another address like this :

    css_minify.php?css=[cssaddress]
    image_compress.php?image=[imageaddress]
    js_packer.php?js=[jsaddress]
    

     

    And also i don't set any expires header in my PHP files (in js_packer.php for example)

    How can i set any expires header in my PHP files?

     

    Thank you  ;D

  4. OP another way(s) that you could do this, if you haven't figure it out already, well I can list a few ways this could be done.

     

    1) You can store an md5sum of all the data on the page in a database or file and check those on each page load.

    2) If your pages are user generated pages from your own site, have the page update on the user saving the page.

    Otherwise (similar to what I mentioned with the HTTP headers)

    3) Use HTTP headers. (304 = not changed) and Etags.

     

    That's all I can think of at the moment.

    here are some links:

    http://en.wikipedia.org/wiki/HTTP_ETag

    http://en.wikipedia.org/wiki/List_of_HTTP_headers

    http://php.net/manual/en/function.header.php

    http://php.net/manual/en/function.md5.php

    http://www.php.net/manual/en/function.md5-file.php

    These two aren't necesarrily mentioned, but an alternative hashing construct in php,

    http://www.php.net/manual/en/function.sha1-file.php

    http://www.php.net/manual/en/function.sha1.php

     

    And for the sake of 'you might find something else useful in this list'

    http://www.php.net/manual/en/ref.strings.php

     

    Thanks for your useful response but i can you please explain HTTP_ETag and give some examples?

     

    And about (304 = not changed), this is only relevant to client and browser cache as far as i know, right?

     

    Thank you  :shy:

     

  5. All friends, thanks for your responds.

     

    Based on my research about caching systems, it's not possible to re-generate cache file only when the file changed, you should use a period (for example 5min) to re-generate cache file or remove all caches and make a new cache file.

     

    This is true?  :shy:

  6. If you do not want to work with time, how do you want to implement that? Asking "when" means using some form of storing information about time. The only other alternative is a tag/category system - you tag the cached content and update the cache explicitely while adding something, requesting i.e. to remove the cache entries with the specified tag.

     

    Thank you dear Zyx,

     

    Many caching systems work with time, it means renew the cache file every 5min etc.

    But i don't want to do that, i want to renew the cache file only WHEN the page content changed...

     

    Thank you again  ::)

  7. Hello,

     

    I'm programming an advanced caching system that work with PHP but i have an small problem.

     

    I want to know when the pages content changed to remove the page cache from cache folder and make a new cache file with new content.

     

    i don't want to work with cache time...

     

    Please help me, thanks a lot.  :)

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.