تحسين الأداء
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
يتناول هذا المستند بعض الأساليب التي يمكنك استخدامها لتحسين أداء تطبيقك. في بعض الحالات، يتم استخدام أمثلة من واجهات برمجة تطبيقات أخرى أو واجهات برمجة تطبيقات عامة لتوضيح الأفكار المعروضة. ومع ذلك، تنطبق المفاهيم نفسها على Campaign Manager 360 API.
الضغط باستخدام gzip
من الطرق السهلة والمريحة لتقليل معدل نقل البيانات المطلوب لكل طلب هي تفعيل ضغط gzip. على الرغم من أنّ هذا يتطلب وقتًا إضافيًا لوحدة المعالجة المركزية لفك ضغط النتائج، إلا أنّ الاستفادة من تكاليف الشبكة عادةً ما تجعل ذلك مفيدًا جدًا.
لتلقي استجابة بترميز gzip، عليك عمل شيئين: ضبط العنوان Accept-Encoding
وتعديل وكيل المستخدم بحيث يتضمن السلسلة gzip
. في ما يلي مثال على عناوين HTTP تم تشكيلها بشكل صحيح لتفعيل ضغط gzip:
Accept-Encoding: gzip
User-Agent: my program (gzip)
العمل مع موارد جزئية
هناك طريقة أخرى لتحسين أداء طلبات البيانات من واجهة برمجة التطبيقات، وهي طلب الجزء الذي يهمّك من البيانات فقط. يتيح ذلك لتطبيقك تجنُّب نقل الحقول غير المطلوبة وتحليلها وتخزينها، ما يتيح له استخدام الموارد، بما في ذلك الشبكة ووحدة المعالجة المركزية والذاكرة، بكفاءة أكبر.
ردّ جزئي
يُرسِل الخادم تلقائيًا التمثيل الكامل لمورد بعد معالجة الطلبات. للحصول على أداء أفضل، يمكنك أن تطلب من الخادم إرسال الحقول التي تحتاجها فقط والحصول على ردّ جزئي بدلاً من ذلك.
لطلب استجابة جزئية، استخدِم مَعلمة طلب fields
لتحديد الحقول التي تريد عرضها. يمكنك استخدام هذه المعلمة مع أي طلب يعرض بيانات الاستجابة.
مثال
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-08-31 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-08-31 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eThis document outlines techniques for enhancing application performance, focusing on reducing bandwidth and resource usage.\u003c/p\u003e\n"],["\u003cp\u003eEnabling gzip compression, by setting specific HTTP headers, minimizes bandwidth consumption, despite requiring extra CPU time for decompression.\u003c/p\u003e\n"],["\u003cp\u003eOptimizing API calls by requesting only necessary data through partial responses, using the \u003ccode\u003efields\u003c/code\u003e parameter, improves network, CPU, and memory efficiency.\u003c/p\u003e\n"]]],[],null,["# Improve Performance\n\nThis document covers some techniques you can use to improve the performance of your application. In some cases, examples from other APIs or generic APIs are used to illustrate the ideas presented. However, the same concepts are applicable to the Campaign Manager 360 API.\n\nCompression using gzip\n----------------------\n\nAn easy and convenient way to reduce the bandwidth needed for each request is to enable gzip compression. Although this requires additional CPU time to uncompress the results, the trade-off with network costs usually makes it very worthwhile.\n\nIn order to receive a gzip-encoded response you must do two things: Set an `Accept-Encoding` header, and modify your user agent to contain the string `gzip`. Here is an example of properly formed HTTP headers for enabling gzip compression: \n\n```perl6\nAccept-Encoding: gzip\nUser-Agent: my program (gzip)\n```\n\nWorking with partial resources\n------------------------------\n\nAnother way to improve the performance of your API calls is by requesting only the portion of the data that you're interested in. This lets your application avoid transferring, parsing, and storing unneeded fields, so it can use resources including network, CPU, and memory more efficiently.\n\n### Partial response\n\nBy default, the server sends back the full representation of a resource after processing requests. For better performance, you can ask the server to send only the fields you really need and get a *partial response* instead.\n\nTo request a partial response, use the `fields` request parameter to specify the fields you want returned. You can use this parameter with any request that returns response data.\n\n#### Example"]]