1

I'm running Apache 2.4.7 on Ubuntu Server 14.04

I have a webserver running. It returns 304 modified for images, but it doesn't return the same for json files. I have checked the answers and comments for this post and this post, however, they don't work for me.

In my .conf file, when I do not load mod_deflate, the server returns a 304 response for my json file. But when I GZIP this file, the server returns 200 OK.

This is what I add to my apache2.conf file:

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
    AddOutputFilterByType DEFLATE application/javascript
</IfModule>

Any workaround to enable both mod_deflate and 304 for .json files?

Thanks!

Community
  • 1
  • 1
wiseindy
  • 19,434
  • 5
  • 27
  • 38
  • I am also looking for a workaround. I have the very same issue, but also with CSS files and JavaScript source files. Turning off mod_deflate gives 304. [A silly bug](https://issues.apache.org/bugzilla/show_bug.cgi?id=45023) from years back has been reopened lately in the Apache bug tracker. [Someone else says](http://codeblow.com/questions/mod-deflate-on-apache-leading-to-browser-to-perform-a-200-rather/) that Etags are to blame. I am continuing investigations. – fcar Oct 25 '14 at 18:30
  • 1
    Anyone else stumbling on this question might be interested in my comment here: http://stackoverflow.com/questions/896974/apache-is-not-sending-304-response-if-mod-deflate-and-addoutputfilterbytype-is#comment-49426848 – Barry Pollard Jun 06 '15 at 13:49
  • Don't set ETag to none, see better fix and explanation http://stackoverflow.com/a/38617597/960020 – Stalingrad Jul 27 '16 at 16:09

1 Answers1

1

Simply set Etag to NONE in apache config.

Having mod_deflate on will append -gzip to Etag, which server then doesn't accept.

Look at the mod_deflate spec

AddSuffix Append the compression method onto the end of the ETag, causing compressed and uncompressed representatins to have unique ETags. This has been the default since 2.4.0, but prevents serving "HTTP Not Modified" (304) responses to conditional requests for compressed content.

Simon B
  • 11
  • 2