Why browser doesn't send If-Modified-Since?










1















I tried to checked already existing questions and answers but couldn't find answer to my topic. Things i checked:



  • i have proper certificate on my domain

  • i am sending proper response headers(at least i think so, blured thing is location header with s3 url):

enter image description here



More information:



  • we use http2.0 from cloudflare, can it affect this anyhow?

  • on our server we use just nginx+php-fpm

What's exactly a scenario - We generate minified images using parameters from post request on our server and save it on S3. I wanted to cache those requests with Last-Modified so browser don't make unnecessary requests, so it looks like currently like this:



  1. Request our server with proper parameters(like image size etc), build some kind of object key for saving into s3

  2. Resize it, upload resized image to S3.

  3. Return image

On next requests:



  1. Request our server, build key again

  2. Check if it exists on S3, if yes, return just redirect to s3 url.

  3. If not then do resize and upload again and return image

I wanted to change this to:



  1. Request our server with proper parameters(like image size etc), build some kind of key for saving

  2. Resize it, upload resized image to S3 if needed

  3. Return image or redirect to s3 with last-modified header.

On next requests:



  1. Check if-modified-since header

  2. If the difference with current date is less than 72h(max s3 url ttl) and image wasn't updated(we have updated date on database) then return 304.

  3. If not then do what's above.

What is even more random, sometimes like 1 per 10 or 20 requests it's working correctly, like i have 304 request sometimes, but it's really rare case.



Any idea?










share|improve this question
























  • Testing without Cloudflare might be interesting... It seems like there are some headers you can use to see what they did...

    – Gert van den Berg
    Dec 14 '18 at 6:34















1















I tried to checked already existing questions and answers but couldn't find answer to my topic. Things i checked:



  • i have proper certificate on my domain

  • i am sending proper response headers(at least i think so, blured thing is location header with s3 url):

enter image description here



More information:



  • we use http2.0 from cloudflare, can it affect this anyhow?

  • on our server we use just nginx+php-fpm

What's exactly a scenario - We generate minified images using parameters from post request on our server and save it on S3. I wanted to cache those requests with Last-Modified so browser don't make unnecessary requests, so it looks like currently like this:



  1. Request our server with proper parameters(like image size etc), build some kind of object key for saving into s3

  2. Resize it, upload resized image to S3.

  3. Return image

On next requests:



  1. Request our server, build key again

  2. Check if it exists on S3, if yes, return just redirect to s3 url.

  3. If not then do resize and upload again and return image

I wanted to change this to:



  1. Request our server with proper parameters(like image size etc), build some kind of key for saving

  2. Resize it, upload resized image to S3 if needed

  3. Return image or redirect to s3 with last-modified header.

On next requests:



  1. Check if-modified-since header

  2. If the difference with current date is less than 72h(max s3 url ttl) and image wasn't updated(we have updated date on database) then return 304.

  3. If not then do what's above.

What is even more random, sometimes like 1 per 10 or 20 requests it's working correctly, like i have 304 request sometimes, but it's really rare case.



Any idea?










share|improve this question
























  • Testing without Cloudflare might be interesting... It seems like there are some headers you can use to see what they did...

    – Gert van den Berg
    Dec 14 '18 at 6:34













1












1








1








I tried to checked already existing questions and answers but couldn't find answer to my topic. Things i checked:



  • i have proper certificate on my domain

  • i am sending proper response headers(at least i think so, blured thing is location header with s3 url):

enter image description here



More information:



  • we use http2.0 from cloudflare, can it affect this anyhow?

  • on our server we use just nginx+php-fpm

What's exactly a scenario - We generate minified images using parameters from post request on our server and save it on S3. I wanted to cache those requests with Last-Modified so browser don't make unnecessary requests, so it looks like currently like this:



  1. Request our server with proper parameters(like image size etc), build some kind of object key for saving into s3

  2. Resize it, upload resized image to S3.

  3. Return image

On next requests:



  1. Request our server, build key again

  2. Check if it exists on S3, if yes, return just redirect to s3 url.

  3. If not then do resize and upload again and return image

I wanted to change this to:



  1. Request our server with proper parameters(like image size etc), build some kind of key for saving

  2. Resize it, upload resized image to S3 if needed

  3. Return image or redirect to s3 with last-modified header.

On next requests:



  1. Check if-modified-since header

  2. If the difference with current date is less than 72h(max s3 url ttl) and image wasn't updated(we have updated date on database) then return 304.

  3. If not then do what's above.

What is even more random, sometimes like 1 per 10 or 20 requests it's working correctly, like i have 304 request sometimes, but it's really rare case.



Any idea?










share|improve this question
















I tried to checked already existing questions and answers but couldn't find answer to my topic. Things i checked:



  • i have proper certificate on my domain

  • i am sending proper response headers(at least i think so, blured thing is location header with s3 url):

enter image description here



More information:



  • we use http2.0 from cloudflare, can it affect this anyhow?

  • on our server we use just nginx+php-fpm

What's exactly a scenario - We generate minified images using parameters from post request on our server and save it on S3. I wanted to cache those requests with Last-Modified so browser don't make unnecessary requests, so it looks like currently like this:



  1. Request our server with proper parameters(like image size etc), build some kind of object key for saving into s3

  2. Resize it, upload resized image to S3.

  3. Return image

On next requests:



  1. Request our server, build key again

  2. Check if it exists on S3, if yes, return just redirect to s3 url.

  3. If not then do resize and upload again and return image

I wanted to change this to:



  1. Request our server with proper parameters(like image size etc), build some kind of key for saving

  2. Resize it, upload resized image to S3 if needed

  3. Return image or redirect to s3 with last-modified header.

On next requests:



  1. Check if-modified-since header

  2. If the difference with current date is less than 72h(max s3 url ttl) and image wasn't updated(we have updated date on database) then return 304.

  3. If not then do what's above.

What is even more random, sometimes like 1 per 10 or 20 requests it's working correctly, like i have 304 request sometimes, but it's really rare case.



Any idea?







http caching amazon-s3 browser-cache cloudflare






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 11:01







Juri

















asked Nov 14 '18 at 10:53









JuriJuri

1,129615




1,129615












  • Testing without Cloudflare might be interesting... It seems like there are some headers you can use to see what they did...

    – Gert van den Berg
    Dec 14 '18 at 6:34

















  • Testing without Cloudflare might be interesting... It seems like there are some headers you can use to see what they did...

    – Gert van den Berg
    Dec 14 '18 at 6:34
















Testing without Cloudflare might be interesting... It seems like there are some headers you can use to see what they did...

– Gert van den Berg
Dec 14 '18 at 6:34





Testing without Cloudflare might be interesting... It seems like there are some headers you can use to see what they did...

– Gert van den Berg
Dec 14 '18 at 6:34












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53298515%2fwhy-browser-doesnt-send-if-modified-since%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53298515%2fwhy-browser-doesnt-send-if-modified-since%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo