rafael abadon 0 Denunciar post Postado Setembro 19, 2014 O google speedpage está acusando a necessidade de aproveitar o cache do navegador para: https://query.yahooapis.com/v1/public/yql?format=json&rnd=20148419&diagnostics=true&callback=jQuery111103910601146053523_1411093592813&q=select%20*%20from%20weather.forecast%20where%20woeid=455832%20and%20u=%22c%22&_=1411093592814 e tambem : http://www.google-analytics.com/analytics.js MEU SITE > https://developers.google.com/speed/pagespeed/insights/?url=arlondrina.com.br&tab=desktop MEU SITE > www.arlondrina.com.br meu código para armazenamento de cache é esse mas preciso de ajuda para solucionar: <IfModule mod_headers.c> Header unset ETag </IfModule> FileETag None <IfModule mod_expires.c> ExpiresActive on ExpiresDefault "access plus 1 month" ExpiresByType text/cache-manifest "access plus 0 seconds" # Html ExpiresByType text/html "access plus 0 seconds" # Data ExpiresByType text/xml "access plus 0 seconds" ExpiresByType application/xml "access plus 0 seconds" ExpiresByType application/json "access plus 0 seconds" # Feed ExpiresByType application/rss+xml "access plus 1 hour" ExpiresByType application/atom+xml "access plus 1 hour" # Favicon ExpiresByType image/x-icon "access plus 1 week" # Media: images, video, audio ExpiresByType image/gif "access plus 1 month" ExpiresByType image/png "access plus 1 month" ExpiresByType image/jpg "access plus 1 month" ExpiresByType image/jpeg "access plus 1 month" ExpiresByType video/ogg "access plus 1 month" ExpiresByType audio/ogg "access plus 1 month" ExpiresByType video/mp4 "access plus 1 month" ExpiresByType video/webm "access plus 1 month" # HTC files ExpiresByType text/x-component "access plus 1 month" # Webfonts ExpiresByType application/x-font-ttf "access plus 1 month" ExpiresByType font/opentype "access plus 1 month" ExpiresByType application/x-font-woff "access plus 1 month" ExpiresByType image/svg+xml "access plus 1 month" ExpiresByType application/vnd.ms-fontobject "access plus 1 month" # CSS / JS ExpiresByType text/css "access plus 1 year" ExpiresByType application/javascript "access plus 1 year" ExpiresByType application/x-javascript "access plus 1 year" </IfModule> #Força o IE a sempre carregar utilizando a última versão disponível <IfModule mod_headers.c> Header set X-UA-Compatible "IE=Edge,chrome=1" <FilesMatch "\.(js|css|gif|png|jpeg|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|oex|xpi|safariextz|vcf)$" > Header unset X-UA-Compatible </FilesMatch> </IfModule> Compartilhar este post Link para o post Compartilhar em outros sites
Marlon Pacheco 132 Denunciar post Postado Setembro 19, 2014 Buenas tchê. Sempre fiz esses testes de performance e com o tempo percebi que nem sempre é possível atender todas as dicas dadas pelo Google/Pingdom. Na minha opinião, isso não é errado. Para esses 2 casos, há uma "gambiarra" que encontrei na web há uns 2 anos atrás. Você teria que "trazer" os arquivos para o seu server, mas aí poderia ter problemas caso o Google/Yahoo modificassem os arquivos. Busquei por uma solução e encontrei o script abaixo (em PHP): <?php // script to update local version of google analytics script // Remote file to download $remoteFile = 'http://www.google-analytics.com/ga.js'; $localfile = '/home/USERNAME/public_html/ga.js'; //For Cpanel it will be /home/USERNAME/public_html/ga.js // Connection time out $connTimeout = 10; $url = parse_url($remoteFile); $host = $url['host']; $path = isset($url['path']) ? $url['path'] : '/'; if (isset($url['query'])) { $path .= '?' . $url['query']; } $port = isset($url['port']) ? $url['port'] : '80'; $fp = @fsockopen($host, '80', $errno, $errstr, $connTimeout ); if(!$fp){ // On connection failure return the cached file (if it exist) if(file_exists($localfile)){ readfile($localfile); } } else { // Send the header information $header = "GET $path HTTP/1.0\r\n"; $header .= "Host: $host\r\n"; $header .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6\r\n"; $header .= "Accept: */*\r\n"; $header .= "Accept-Language: en-us,en;q=0.5\r\n"; $header .= "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n"; $header .= "Keep-Alive: 300\r\n"; $header .= "Connection: keep-alive\r\n"; $header .= "Referer: http://$host\r\n\r\n"; fputs($fp, $header); $response = ''; // Get the response from the remote server while($line = fread($fp, 4096)){ $response .= $line; } // Close the connection fclose( $fp ); // Remove the headers $pos = strpos($response, "\r\n\r\n"); $response = substr($response, $pos + 4); // Return the processed response echo $response; // Save the response to the local file if(!file_exists($localfile)){ // Try to create the file, if doesn't exist fopen($localfile, 'w'); } if(is_writable($localfile)) { if($fp = fopen($localfile, 'w')){ fwrite($fp, $response); fclose($fp); } } } ?> Com esse script no seu server, você precisa colocá-lo para execução periódica, via CRON. Assim, você teria sempre a última versão do script do seu server. Compartilhar este post Link para o post Compartilhar em outros sites