Browser cache management, dynamic content

Problem: I cannot force FireFox to cache images sent from a dynamic server

Configuration: Static Apache server with reverse proxy to the dynamic server (mod_perl2) on the server.

Here is the request URL for the server. It is sent to a dynamic server, where a cookie is used to check access to the image:

Request Headers

Host:  <OBSCURED>
User-Agent:  Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.15) Gecko/2009102815 Ubuntu/9.04 (jaunty) Firefox/3.0.15
Accept:  image/png,image/*;q=0.8,*/*;q=0.5
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:  300
Connection:  keep-alive
Referer: <OBSCURED>
Cookie:  pz_cred=4KCNr0RM15%2FJCOt%2BEa6%2BL62z%2Fxvbp2xNQHY5pJw5d6Q
Pragma:  no-cache
Cache-Control: no-cache

The dynamic server transfers the image back to the server and provides the following response:

Answer Headers

Date:  Tue, 24 Nov 2009 04:28:07 GMT
Server:  Apache/2.2.11 (Ubuntu) mod_apreq2-20051231/2.6.0 mod_perl/2.0.4 Perl/v5.10.0
Cache-Control: public, max-age=31536000
Content-Length:  25496
Content-Type:  image/jpeg
Via: 1.1 127.0.1.1:8081
Keep-Alive:  timeout=15, max=75
Connection:  Keep-Alive

So far, so good (I think). However, when the page is reloaded, the image does not appear in the cache, and the request is sent again:

Request Headers

Host: <OBSCURED>
User-Agent:  Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.15) Gecko/2009102815 Ubuntu/9.04 (jaunty) Firefox/3.0.15
Accept:  image/png,image/*;q=0.8,*/*;q=0.5
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:  300
Connection:  keep-alive
Referer: <OBSCURED>
Cookie:  pz_cred=4KCNr0RM15%2FJCOt%2BEa6%2BL62z%2Fxvbp2xNQHY5pJw5d6Q
Cache-Control: max-age=0

, , . , 200, , , ( , , ).

, -, Cache-Control: max-age = 0 .

- , ? , Via , ?

+3
3

.

, FireFox 3 . -, . , Cache-Control: max-age=0.

Firefox , , " ". , .

, , YSlow . .

script , "If-Modified-Since". , , , HTTP_NOT_MODIFIED (304).

- , Firefox , . , Firefox , .

: - , (+1 Jim). , , (, AJAX ), .

, -, :)

+3

Cache-Control: no-cache

HTTP- ( Firefox), , - .

:

Cache-Control: public, max-age=31536000

, . , , PNG: HTTP 1.1 ( 14.21):

: Cache-Control (. 14.9.3), Expires.

:

Cache-Control: max-age=0

HTTP-, 0 .

, : "" Firefox, -. , . , , max-age = 0 , .

, FireBug Firefox. .

+5

:

  • Last-Modified
  • ​​ .

Firebug - 200 , YSlow . YSlow, 500K; , 0.

Origin, :

Date: Tue, 24 Nov 2009 08:54:24 GMT
Server: Apache/2.2.11 (Ubuntu) mod_apreq2-20051231/2.6.0 mod_perl/2.0.4 Perl/v5.10.0
Last-Modified: Sun, 22 Nov 2009 07:28:25 GMT
Expires: Tue, 30 Nov 2010 19:00:25 GMT
Content-Length: 10883
Content-Type: image/jpeg
Keep-Alive: timeout=15, max=89
Connection: Keep-Alive

- , , , ; URL- URL- , . http://myserver.com/img/125.jpg?20091122 ( AJAX JSON). , 01 2000 2050 .

YSlow - , - FireBug - 200.

+1

Source: https://habr.com/ru/post/1723743/


All Articles