الكل بالطبع يسعى لتحسين أداء موقعه من خلال تسريع الموقع تارة ومن خلال توفير ترافيك الاستضافة الشهري تارة اخرى..فما بالك لو كانو الاثنين معاً...
نعم هذا صحيح .. و الكلمة المفتاحية لموضوعنا هنا هو الكاش
الكاش: هو تخزين محتويات موقعك الذي يقوم بتنزيلها الزائر من موقعك بمجرد تصفحه مثل ملفات الجافا و الـ css الخارجية و ايضاً الصور .. و بتطويل مدة تخزين هذه الملفات و الصور .. لن ينزل الزائر هذه الملفات المكررة التي تؤدي لبطئ موقعك كل مرة..
التركيب:
نقوم بعمل ملف htaccess. ونكتب فيه هذه السطور البسيطة :
CODE
# YEAR
<FilesMatch "\.(flv|gif|ico|png|jpg)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
# WEEK
<FilesMatch "\.(pdf|swf|js|css)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
# NEVER CACHE
<FilesMatch "\.(html|cgi|php|htm)$">
Header set Expires "Thu, 01 Dec 2003 16:00:00 GMT"
Header set Cache-Control "no-store, no-cache, must-revalidate"
Header set Pragma "no-cache"
</FilesMatch>
كما هو موضح أمامكم هو يقوم بالاتي:
تخزين نوعية ملفات flv|gif|ico|png|jpg|swf لمدة سنة
تخزين نوعية ملفات pdf|swf|js|css لمدة أسبوع
لا يقوم بتخزين نوعية ملفات html|cgi|php|htm أبداً (وهذا حتى تعرف تعدل على موقعك في اي وقت تشاء لان به محتوى موقعك)
وهناك أيضاً خيار ضغط الملفات في حالة عدم تفعيله تلقائياً بالسيرفر..نقوم بكتابتها في htaccess. وتكون كالاتي
يمكنك قياس سرعة موقعك قبل هذا التعديل و بعده و مشاركتنا النتائج بالموضوع من خلال الموقعhttp://gtmetrix.com/
والذي يقوم بقياس موقعك بالــ page speed و YSLOW من غير تركيبهما على متصفح الفايرفوكس
# setup errordocumen ts to local php file
ErrorDocumen t 404 /cgi-bin/error.htm
ErrorDocumen t 403 /cgi-bin/error.htm
ErrorDocumen t 500 /cgi-bin/error.htm
# Turn on Expires and set default to 0
ExpiresActive On
ExpiresDefault A0
# Set up caching on media files for 1 year (forever?)
<FilesMatch "\.(ico|flv|pdf|mov|mp3|wmv|ppt)$">
ExpiresDefault A29030400
Header append Cache-Control "public"
</FilesMatch>
# Set up caching on media files for 1 month
<FilesMatch "\.(gif|jpg|jpeg|png|swf|js|css)$">
ExpiresDefault A2419200
Header append Cache-Control "public, proxy-revalidate"
</FilesMatch>
# Set up caching on media files for 1 week
<FilesMatch "\.(xml|txt|html)$">
ExpiresDefault A604800
Header append Cache-Control "public, proxy-revalidate"
</FilesMatch>
# Force no caching for dynamic files
<FilesMatch "\.(php|cgi|pl|htm)$">
ExpiresDefault A0
Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, no-transform"
Header set Pragma "no-cache"
</FilesMatch>
يتم تركيبه مع حذف المسافة في كلمة Documen t
ExpiresDefault A0 : حيث التخزين الافتراضي لغير صيغ الملفات المكتوبة هي صفر
بعد التجربة...وجدت ان له قدرة اعلى في تخزين الصور والملفات
و بالاخص الصور وملفات الجافا التي تخص المواقع الخارجية مثل زر تويتر و فيس بوك و add this و خلافه,,
وهذا بعد اختبار منتداي مرة اخرى (بعد تركيب أعجبني لصفحة الموقع الفيس بوك)
المشاركة الأصلية كتبت بواسطة: akroum روعة لكن عندي سؤال . مثلا عندي صور اسمها 1 وقمت بحدفها نهائيا ووضعت صورة اخرى مكانها . هل يجب أن أغير اسمها لكي تحدت أم مادا
يا سلام...سؤال في محله
الحل من هنا :
اقتبـاس ،،
The requests from browsers, therefore, result in one of the following response status codes:
200 — The browser does not have the image in its cache
304 — The browser has the image in its cache, but needs to verify the last modified date
بمعنى ان طلبات التحميل من موقعك على المتصفحات تكون في حالتين...
الحالة 200 : ان الملف لم يتم تخزينه بالاصل.
الحالة 304 : أن الملف تم تخزينه من قبل لكن يحتاج الى تحديث,,
و أي استفسارات انا متابع معاكم,,
( تحديث ) : تسريع موقعك/منتداك بنسبة كبيرة + توفير الترافيك الشهري
لما وضعت الكود في اخر ملف htaccess
ظهر لي الخطأ الاتي
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator,[email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
ما رأيك اخ محمد ؟