2009-11-09 14 views
25

पर विचार करें इस परिदृश्य:कैशिंग प्रॉक्सी का अनुरोध करता है

  • मैं RESTful यूआरएल/लेख है कि रिटर्न लेखों की सूची
  • उपयोगकर्ता प्रत्येक अनुरोध
  • लेख भिन्न हो सकते हैं पर प्राधिकरण HTTP शीर्ष लेख का उपयोग कर अपने क्रेडेंशियल प्रदान किया है उपयोगकर्ता से अपने विशेषाधिकारों के आधार पर उपयोगकर्ता से

इस परिदृश्य के लिए स्क्विड जैसे कैशिंग प्रॉक्सी का उपयोग करना संभव है? प्रॉक्सी केवल यूआरएल/लेख देखेंगे, इसलिए यह कैश उत्पन्न करने वाले पहले उपयोगकर्ता के लिए मान्य लेखों की सूची लौटा सकता है। यूआरएल/लेखों का अनुरोध करने वाले अन्य उपयोगकर्ता उन लेखों को देख सकते हैं जिनके पास पहुंच नहीं है, जो निश्चित रूप से वांछनीय नहीं है।

क्या मुझे अपना कैश रोल करना चाहिए या कुछ कैशिंग प्रॉक्सी सॉफ़्टवेयर प्राधिकरण HTTP शीर्षलेख पर अपने कैश को आधार के लिए कॉन्फ़िगर किया जा सकता है?

उत्तर

29

अनुरोध करने की संभावना Vary: Authorization प्रतिक्रिया शीर्षलेख का उपयोग कर डाउनस्ट्रीम कैश को अनुरोध के Authorization शीर्षलेख के आधार पर कैश किए गए दस्तावेज़ों को अलग करके कैशिंग के बारे में सावधान रहने के निर्देश देने के लिए है।

यदि आप प्रतिक्रिया-संपीड़न का उपयोग करते हैं तो आप पहले ही इस हेडर का उपयोग कर रहे हैं। उपयोगकर्ता आमतौर पर हेडर Accept-Encoding: gzip, deflate के साथ संसाधन का अनुरोध करता है; यदि सर्वर संपीड़न का समर्थन करने के लिए कॉन्फ़िगर किया गया है, तो प्रतिक्रिया शीर्षलेख Content-Encoding: gzip और Vary: Accept-Encoding से पहले ही हो सकती है।

+1

हाँ, वैरी हैडर चाल करना चाहिए। धन्यवाद। – Peter

+1

बढ़िया! एक अपवित्र के लिए निर्बाध याचिका, फिर? – yfeldblum

+0

यदि आप HTTPS का उपयोग करते हैं तो यह भी एक मुद्दा है? (यदि आप मूल प्रमाणीकरण या प्राधिकरण शीर्षलेख का उपयोग कर रहे हैं तो इसका उपयोग किया जाना चाहिए) – wal

9

HTTP/1.1 आरएफसी खंड 14.8 (http://tools.ietf.org/html/rfc2616#section-14.8) द्वारा:

When a shared cache (see section 13.7) receives a request 
    containing an Authorization field, it MUST NOT return the 
    corresponding response as a reply to any other request, unless one 
    of the following specific exceptions holds: 

    1. If the response includes the "s-maxage" cache-control 
    directive, the cache MAY use that response in replying to a 
    subsequent request. But (if the specified maximum age has 
    passed) a proxy cache MUST first revalidate it with the origin 
    server, using the request-headers from the new request to allow 
    the origin server to authenticate the new request. (This is the 
    defined behavior for s-maxage.) If the response includes "s- 
    maxage=0", the proxy MUST always revalidate it before re-using 
    it. 

    2. If the response includes the "must-revalidate" cache-control 
    directive, the cache MAY use that response in replying to a 
    subsequent request. But if the response is stale, all caches 
    MUST first revalidate it with the origin server, using the 
    request-headers from the new request to allow the origin server 
    to authenticate the new request. 

    3. If the response includes the "public" cache-control directive, 
    it MAY be returned in reply to any subsequent request. 
+1

मुझे लगता है कि प्रश्नकर्ता 'कैश-कंट्रोल' हेडर में 'सार्वजनिक' ध्वज का उपयोग करता है। आपकी पोस्ट प्रश्न का उत्तर नहीं देती है, लेकिन यह सहायक है। – dizel3d

संबंधित मुद्दे