سؤال

أحاول تمكين رؤوس الصور الخاصة بالصور كما يوصى به Yslow. أنا متأكد من أنني كان لدي هذا يعمل من قبل ولكن الآن عندما أتحقق من Yslow، تقول إنهم لا يتم تخزين مؤقتا.

بالنسبة لي .htaccess، لقد حاولت:

ExpiresActive on
ExpiresDefault A0
<FilesMatch "\.(gif|ico|jpg|png)$">
    ExpiresDefault A29030400
    Header append Cache-Control "public"
</FilesMatch>

و

ExpiresActive on
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"

http://www.seoconsultants.com/tools/headers.asp. مخرجات ما يلي لأحد صوري:

HTTP Status Code: HTTP/1.1 200 OK
Date: Mon, 05 Oct 2009 20:12:04 GMT
Server: Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 PHP/5.2.8
X-Powered-By: PHP/5.2.8
Set-Cookie: PHPSESSID=5d11f4d8aa37ceee6605786e59ff4f0f; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: lastlogin=1254773024; expires=Mon, 02-Nov-2009 20:12:04 GMT
Connection: close
Content-Type: image/jpeg

يبدو الجزء المحدد ملف تعريف الارتباط صحيحا ولكن رأس تنتهي صلاحيته ليس كذلك. كيف أضع تنتهي صلاحيته بشكل صحيح ولماذا تختلف؟ لقد فحصت مزدوجة أن mod_expires ويتم تمكين mod_headers.

هل كانت مفيدة؟

المحلول

من رأس ملف تعريف الارتباط، يبدو أن هذا جزء من جلسة PHP. PHP تعطيل تلقائيا التخزين المؤقت بعد جلسة_Start ().

يمكنك تعديل هذا السلوك عن طريق تغيير Session.cache_limiter في PHP.INI الخاص بك. يرى صفحة دليل PHP للحصول على الإعدادات المختلفة.

بدلا من ذلك، يمكنك محاولة استخدام "تعيين" بدلا من "إلحاق" لتجاوز الرؤوس في .htaccess.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top