Forum Moderators: phranque

Message Too Old, No Replies

Chrome is not caching images, css, js files.

Something wrong with server headers i think

         

Seregwethrin

6:47 pm on Dec 9, 2008 (gmt 0)

10+ Year Member



Hello;

I've tried a lot of combinations of headers with etag, cache-control, expires but still Google Chrome is not caching files (jpg jpeg gif png js css etc...).

Apache is not sending last-modified, content-type and content-lenght headers for images and css js files from web pages, that's mean it sends but only when you enter directly to the file (like xx.com/xx.jpg), not sending from html pages (checked at Firebug, also other sites look sending fine at Firebug).

What do i must do to send headers for last-modified content-type and content-lenght? (I think because of those, Chrome is not caching images and depency files.)

[edited by: Seregwethrin at 7:36 pm (utc) on Dec. 9, 2008]

jdMorgan

7:28 pm on Dec 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is your site static, or do your generate pages on-the-fly with PHP, ASP, etc.?

What are the values of the expires and cache-control headers you are sending now for these files? And how are you generating and sending them?

Jim

Seregwethrin

7:48 pm on Dec 9, 2008 (gmt 0)

10+ Year Member



I'm using php but jpg, gif, png, css, js files nothing to do with php I think.

I'm the server's owner, I've access httpd.conf and all other files

I've those lines and changed them, commented some, uncommented some but couldn't get any successful result.

<FilesMatch "\.(ico如df夸pg夸peg如ng夙if夸s圭ss存wf圩lv)$">
#ExpiresActive On
#ExpiresDefault "access plus 1 day"
Header unset Pragma
Header unset ETag
FileETag None
#Header unset Last-Modified
Header set Cache-Control "public, max-age=86400"
</FilesMatch>

[edited by: Seregwethrin at 7:55 pm (utc) on Dec. 9, 2008]

jdMorgan

8:35 pm on Dec 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here's what I'm using for those kinds of files:

# Set up Cache Control headers

# Activate mod_expires
ExpiresActive On

<FilesMatch "\.(gif夸pe?g如ng夷co圭ss夸s存wf圩lv如df)$">
# Set expiry at 30 days after access
ExpiresDefault A2592000

# Remove cache-control headers (use default client behavior)
Header unset Cache-Control:

# Remove host's default 'Vary: User-Agent' response header
Header unset Vary:
</FilesMatch>

The resulting relevant server response headers for a .gif image request are:

HTTP/1.x 200 OK
Date: Tue, 09 Dec 2008 20:22:13 GMT
Server: Apache
Cache-Control: max-age=2592000
Expires: Thu, 08 Jan 2009 20:22:13 GMT
Last-Modified: Wed, 20 Dec 2006 23:52:40 GMT
Etag: "3647960-14b5-4589ccc8"
Accept-Ranges: bytes
Content-Length: 5301
Content-Type: image/gif

I recommend using the "Live HTTP Headers" add-on for Firefox and Mozilla-based browsers. It will give you the 'real' browser view of HTTP client request headers and server response headers, and is not subject to the limitations of on-line headers checkers. Combine it with an add-on that allows you to change the user-agent string for a fairly-powerful tool-set.

Jim