redbox-cdn opened a new issue #1570: PageSpeed could not optimize (Proxy_pass) 
if response returned 200
URL: https://github.com/apache/incubator-pagespeed-ngx/issues/1570
 
 
   Hi.
   I feel something strange is going on pagespeed optimize action.
   
   Situation: 
   Client -- Nginx(pagespeed and Proxy_pass) -- Origin Web server
   
   Client send request into Pagespeed including "if modify since" header,
   Pagespeed does not optimize if origin Web server return 304. 
   
   So, I added the `proxy_set_header If-Modified-Since "";` proxy_pass 
directive.
   After that Origin Web server response is 200 but Pagespeed could not 
optimize.
   
   ### nginx Debug message
   
   `[ngx_pagespeed 1.13.35.1-0] Could not rewrite resource in-place because URL 
is not in cache: http://test.com/test/test.css`
   
   ### TEST request
   
   `curl -svko /dev/null 'http://1.1.1.1/test/test.css' -H 'Host: test.com' -H 
'X-forwarded-proto: https' -H 'pragma: no-cache' -H 'cache-control: no-cache' 
-H 'If-Modified-Since: Mon, 04 Jun 2018 09:00:52 GMT'
   `
   
   ### Origin Server response
   
   ```
   < HTTP/1.1 200 OK
   < Date: Fri, 08 Jun 2018 02:48:01 GMT
   < Content-Type: text/css
   < Content-Length: 198
   < Connection: keep-alive
   < Vary: Accept-Encoding
   < Last-Modified: Mon, 04 Jun 2018 09:00:52 GMT
   < Accept-Ranges: bytes
   < Cache-Control: max-age=3024000
   < Expires: Fri, 13 Jul 2018 02:48:01 GMT
   < Vary: Accept-Encoding
   < Access-Control-Allow-Origin: *
   < Access-Control-Allow-Headers: Content-Type
   < Access-Control-Allow-Credentials: true
   < Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
   ```
   
   ### Nginx conf
   ```
   server {
   
       listen 80;
   
       location / {
   
           proxy_set_header If-Modified-Since ""; ## ADD
   
           proxy_read_timeout 3600;
           more_clear_headers Server: ;
           proxy_http_version 1.1;
           proxy_set_header Connection "";
           resolver_timeout 300s;
           resolver 8.8.8.8 8.8.4.4 valid=300s;
           proxy_pass  $http_backend_schema://test.com;
           proxy_set_header Host                   $host;
           proxy_redirect     off;
           }
   
       pagespeed on;
   
       location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
           add_header "" "";
       }
       ##Cache Settings
   
       pagespeed FileCacheSizeKb            10000;
       pagespeed FileCacheCleanIntervalMs   5000;
       pagespeed FileCacheInodeLimit        100;
       pagespeed FileCachePath /home/cache
       pagespeed ImplicitCacheTtlMs 1;
       pagespeed ModifyCachingHeaders off;
       pagespeed EnableFilters in_place_optimize_for_browser;
       pagespeed HttpCacheCompressionLevel 0;
       pagespeed CriticalImagesBeaconEnabled false;
       pagespeed InPlaceResourceOptimization on;
       pagespeed PreserveUrlRelativity on;
       pagespeed JsPreserveURLs on;
       pagespeed ImagePreserveURLs on;
       pagespeed CssPreserveURLs on;
       pagespeed DownstreamCachePurgeLocationPrefix "http://localhost/purge";;
       pagespeed DownstreamCachePurgeMethod "POST";
       pagespeed DownstreamCacheRebeaconingKey "test";
       pagespeed CustomFetchHeader X-Forwarded-proto $http_x_forwarded_proto;
       pagespeed RateLimitBackgroundFetches off;
   
       pagespeed RewriteLevel PassThrough;
       pagespeed EnableFilters 
add_head,rewrite_css,flatten_css_imports,fallback_rewrite_css_urls,rewrite_javascript,remove_comments,insert_dns_prefetch,in_place_optimize_for_browser;
   
       #Purge request
       pagespeed PurgeMethod PURGE;
       pagespeed EnableCachePurge on;
   }
   ```
   
   Does anyone know something good solution?
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to