Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

304 not modified on static files

Tags:

After moving the project to the production server, I found that static files, such as images, will not be returned with status "304 not modified", although there are cache headlines like "Last-Modified" and "Expires".

Request Headers

Accept:image/webp,image/*,*/*;q=0.8 Accept-Encoding:gzip, deflate, sdch Accept-Language:ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4,uk;q=0.2 Cache-Control:max-age=0 Connection:keep-alive Cookie:_LANG=ru DNT:1 Host:test.com If-Modified-Since:Mon, 07 Sep 2015 08:46:37 GMT If-None-Match:"1D0E949B4DCD480" Referer:http://test.com/ru/Some/Index/ User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML,     like Gecko) Chrome/45.0.2454.85 Safari/537.36 

Response headers

HTTP/1.1 200 OK Cache-Control: public Content-Type: image/png Expires: Tue, 08 Sep 2015 14:33:06 GMT Last-Modified: Mon, 07 Sep 2015 08:46:37 GMT Accept-Ranges: bytes ETag: "1D0E949B4DCD480" Server: Microsoft-IIS/8.0 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Date: Mon, 07 Sep 2015 14:33:06 GMT Content-Length: 5953 

At the local "IIS express" everything works correctly.

Local response headers

HTTP/1.1 304 Not Modified Cache-Control:public Date:Mon, 07 Sep 2015 14:38:12 GMT Etag:"1D04A9052E17E00" 

Prompt, in what could be the reason?

Web.config files are identical.

Thanks!

UPD 1:

chrome network console chrome request

UPD 2:

Local machine cache snapshot returns images

C:\Users\dev>netsh http show cachestate  Snapshot cache responses HTTP:: --------------------------------  URL-address: http://dev2-pc:1437/Views/CustomMeme/byby/img/header.jpg Status Code: 200 Команда HTTP: GET Тип политики кэша: Срок жизни (TTL) Срок жизни записи в кэше (сек): 86399 Время создания: 2015.9.8:12.14.41:0 Имя очереди запросов: Clr4IntegratedAppPool{737BCE3B-FD81-4AB4-B976-A3A8C8A-94D8} Тип содержимого: image/jpeg Кодировка содержимого: (null) Длина заголовков: 415 Длина содержимого: 49017 Число обращений: 3 Принудительное отключение после обслуживания: FALSE 

But remote (production) server cache snapshot is empty

C:\Users\Администратор>netsh http show cachestate  Snapshot cache HTTP responses: -------------------------------- The cache contains entries that match the specified URL-address 
like image 794
dima_horror Avatar asked Sep 07 '15 14:09

dima_horror


People also ask

What does 304 not modified mean?

The HTTP 304 Not Modified client redirection response code indicates that there is no need to retransmit the requested resources. It is an implicit redirection to a cached resource.

How do I fix error 304 in IIS?

js file to be cached you'll either need to set the no-cache directive in the app (ie- the ASP.NET code) or you'll need to change the Cache-Control header in the request to use the no-store directive instead of no-cache .

What does code 304 mean?

The HTTP status code 304 means Not Modified – the web page you requested hasn't changed since the last time you accessed it. After that, your browser will retrieve the cached version of the web page in your local storage.


1 Answers

Refer Below link and enabling cache manually for contents type based on your requirement and see if its works or not.

https://www.iis.net/configreference/system.webserver/caching

like image 129
Vijay Kumar Singh Avatar answered Oct 04 '22 20:10

Vijay Kumar Singh