<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Süleyman Tülbür on Medium]]></title>
        <description><![CDATA[Stories by Süleyman Tülbür on Medium]]></description>
        <link>https://medium.com/@suleymantulburdev?source=rss-cf39c7da6d48------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Süleyman Tülbür on Medium</title>
            <link>https://medium.com/@suleymantulburdev?source=rss-cf39c7da6d48------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 23:45:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@suleymantulburdev/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Mastering SSL Pinning: Overcoming Operational Issues in SSL Pinning with Intermediate Certificate…]]></title>
            <link>https://suleymantulburdev.medium.com/mastering-ssl-pinning-overcoming-operational-issues-in-ssl-pinning-with-intermediate-certificate-9b9f4ce94d38?source=rss-cf39c7da6d48------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b9f4ce94d38</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[ssl-pinning]]></category>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Süleyman Tülbür]]></dc:creator>
            <pubDate>Sat, 04 Jan 2025 21:54:44 GMT</pubDate>
            <atom:updated>2025-01-04T21:54:44.447Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mastering SSL Pinning: Overcoming Operational Issues in SSL Pinning with Intermediate Certificate and Subject Validation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7MO0HiKJR6gS0sZKEudi-Q.jpeg" /></figure><p>SSL Pinning is a technique employed to enhance the network security of mobile applications. It is fundamentally based on verifying the server’s certificate against a certificate or key embedded within the application. By completing these verifications, SSL Pinning ensures that no unauthorized connection can interfere between the client and the server.</p><h4><strong>Types of SSL Pinning</strong></h4><p>Although there are many methods for the SSL pinning method to be applied, the basis of all these methods consists of two main methods:</p><ul><li><strong>Certificate Pinning</strong></li><li><strong>Public Key Pinning</strong></li></ul><p>The aim of this article is not to delve into these methods in detail. There are already numerous resources that thoroughly explain how to implement SSL Pinning. If you are unfamiliar with the basics of SSL Pinning, I recommend exploring foundational resources before proceeding.</p><p>Both certificate pinning and public key pinning offer robust security mechanisms. However, this article is written to address a different aspect of SSL Pinning: the challenges encountered during the renewal of SSL certificates in a production environment.</p><h4>The Problem</h4><p>At my workplace, we faced several issues when renewing SSL certificates. For instance, updated certificates in new app versions were sometimes rejected by app stores, leaving our users unable to access the application. Although we experimented with various methods to automate certificate updates and resolve these problems, most of them were merely workarounds and lacked a permanent solution.</p><h4>The Solution: Pinning the Intermediate Certificate</h4><p>To address these challenges, we opted for <strong>Intermediate Certificate Pinning</strong>. Unlike pinning the server certificate directly, this method involves pinning the intermediate certificate in the chain of trust. This approach offered a more flexible and resilient solution for the following reasons:</p><ol><li><strong>Certificate Renewal Flexibility</strong>: Server certificates typically have a shorter lifespan (e.g., 1 year). By pinning the intermediate certificate — which often has a longer validity period (e.g., 5–10 years) — we eliminated the need to update the application with every server certificate renewal.</li><li><strong>Compatibility Across Environments</strong>: Pinning an intermediate certificate ensured compatibility across different environments (e.g., development, staging, production) as long as the server certificate was issued by the same Certificate Authority (CA).</li><li><strong>Reduced Risk of App Store Rejections</strong>: Since the pinned certificate remained valid for a longer duration, there was no need for frequent app updates to accommodate certificate renewals, minimizing the likelihood of app store rejections.</li></ol><h4>Implementation Steps</h4><p>Here’s how we implemented Intermediate Certificate Pinning in our application:</p><ol><li><strong>Extracting the Intermediate Certificate</strong>: Obtain the intermediate certificate from the server certificate chain. This can be done using tools like OpenSSL.</li><li><strong>Embedding the Certificate in the Application</strong>: Add the intermediate certificate as a static resource in your application. Ensure it is securely stored to prevent tampering.</li><li><strong>Updating the Pinning Logic</strong>: Modify the SSL Pinning logic to verify the server certificate against the embedded intermediate certificate rather than the server certificate itself.</li><li><strong>Testing Across Environments</strong>: Conduct thorough testing to ensure the application communicates securely across all environments.</li></ol><h3>Additional Security Measures</h3><p>To further enhance security beyond intermediate certificate pinning, we implemented an <strong>additional control mechanism</strong>. This mechanism involves verifying the <strong>Subject (CN, O, L, ST, C values)</strong> of the server certificate.</p><h4>What is Subject Validation?</h4><p>The subject of an SSL certificate includes key information about the entity that owns the certificate. These fields typically include:</p><ul><li><strong>CN (Common Name)</strong>: The hostname of the server.</li><li><strong>O (Organization)</strong>: The name of the organization owning the certificate.</li><li><strong>L (Locality)</strong>: The city where the organization is located.</li><li><strong>ST (State/Province)</strong>: The state or province of the organization.</li><li><strong>C (Country)</strong>: The country of the organization.</li></ul><h4>How Does This Work?</h4><ul><li><strong>Extract Subject Fields</strong>: During the SSL handshake, extract the subject fields from the server certificate.</li><li><strong>Compare with Expected Values</strong>: Match these fields against predefined expected values in the application.</li><li><strong>Terminate on Mismatch</strong>: If any field does not match, terminate the connection immediately.</li></ul><p>This step ensures that even if the intermediate certificate matches, the connection is further secured by validating the identity of the server.</p><h4>Hands-On: Implementing Intermediate Certificate Pinning and Subject Validation</h4><p>In this section, we’ll implement intermediate certificate pinning with subject validation step by step. We’ll go through each component and explain how they work together to provide a secure SSL pinning solution.</p><h4>Core Implementation</h4><p>Let’s start with the base implementation and then break down each component:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fea1a70e4a6ef0c01e642493ec3cba78/href">https://medium.com/media/fea1a70e4a6ef0c01e642493ec3cba78/href</a></iframe><h4>URLSession Challenge Handling</h4><p>This is where the SSL/TLS challenge is processed:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a77d2bbd154b8ddd8b6dcfca50d96380/href">https://medium.com/media/a77d2bbd154b8ddd8b6dcfca50d96380/href</a></iframe><h4>Certificate Validation Methods</h4><p>These methods handle the different aspects of certificate validation:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b016810b270f51977126587454354a18/href">https://medium.com/media/b016810b270f51977126587454354a18/href</a></iframe><h4>Subject Validation Implementation</h4><p>The subject validation is handled through these structures and methods:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/55198921158dd6c2b4a4d5373d29ecf2/href">https://medium.com/media/55198921158dd6c2b4a4d5373d29ecf2/href</a></iframe><h4>Conclusion</h4><p>By combining <strong>Intermediate Certificate Pinning</strong> and <strong>Subject Validation</strong>, we achieved a multilayered approach to securing our mobile application’s network communication. This not only mitigates the risks associated with certificate renewals but also adds an additional layer of verification to protect against advanced threats.</p><p>Through these techniques, we were able to maintain operational flexibility while significantly enhancing the security of our application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b9f4ce94d38" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GCD: Debouncing and Throttling for Efficient Task Management in Swift]]></title>
            <link>https://suleymantulburdev.medium.com/gcd-debouncing-and-throttling-for-efficient-task-management-in-swift-8cee2c539b12?source=rss-cf39c7da6d48------2</link>
            <guid isPermaLink="false">https://medium.com/p/8cee2c539b12</guid>
            <category><![CDATA[xcode]]></category>
            <category><![CDATA[concurrency]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Süleyman Tülbür]]></dc:creator>
            <pubDate>Sat, 04 Jan 2025 21:53:46 GMT</pubDate>
            <atom:updated>2025-01-04T21:53:46.188Z</atom:updated>
            <content:encoded><![CDATA[<p>Modern applications demand efficient performance optimization and resource management strategies to ensure a seamless user experience. High-frequency user interactions or background processes can overload system resources, leading to sluggish performance, wasted resources, and a frustrated users.</p><p>Two effective techniques to tackle these challenges are debouncing and throttling. These strategies reduce redundant tasks, optimize resources, and stabilize applications. iOS developers can rely on Grand Central Dispatch (GCD) to implement these techniques.</p><h4>Grand Central Dispatch (GCD)</h4><h4>Why GCD Matters</h4><p>Think of GCD as our app’s multitasking assistant. It handles the heavy lifting of thread management, letting us focus on building features instead of worrying about thread safety or resource allocation. GCD manage tasks using dispatch queues, efficiently distributing them across processor cores. Whether you’re updating a UI or fetcing data in the background, GCD ensures smooth execution.</p><h4>Types of Dispatch Queues</h4><ul><li><strong>Main Queue</strong>: For UI updates and user tasks.</li><li><strong>Global Queues</strong>: System-managed concurrent queues with various QOS(quality of service).</li><li><strong>Custom Queues</strong>: User defined serial or concurrent queues.</li></ul><h3>Debouncing</h3><h4>How It Works</h4><p>Ever been indecisive while typing in a search bar? With every keystroke, debouncing kicks in, resetting a timer. Only when you pause does main action execute.</p><h4>Benefits</h4><ul><li>Prevents unnecessary operations. For example, repeated network requests</li><li>Makes apps more responsive and avoids more server load.</li></ul><h4>Real-World Use Cases</h4><ul><li><strong>Search Suggestions</strong>: Google Search doesn’t send a request for every character you type. It waits until you stop, thanks to debouncing.</li><li><strong>Form Submissions</strong>: Platforms like Twitter ensure users don’t accidentally double submit a form by debouncing button clicks.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8cb47bbd968c0a0945f97344ef6032e/href">https://medium.com/media/d8cb47bbd968c0a0945f97344ef6032e/href</a></iframe><h3>Throttling</h3><h4>How It Works</h4><p>Unlike debouncing, throttling guarantees periodic task execution, even if triggered multiple times. For instance, while scrolling on Facebook, data loads every few seconds, not with every motion of your finger.</p><h4>Variants</h4><ul><li><strong>Leading</strong>: Executes immediately but ignores subsequent events until the interval ends.</li><li><strong>Trailing</strong>: Waits until the interval ends then processes the latest event.</li><li><strong>Hybrid</strong>: Combines the two, running once immediately and again at the interval’s end.</li></ul><h4>Real-World Examples</h4><ul><li><strong>Infinite Scroll</strong>: Social apps like TikTok or Instagram throttle network calls for content, balancing speed and server load.</li><li><strong>Navigation Apps</strong>: Google Maps throttles updates as you drag the map, ensuring smooth performance without over computation.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2e6590583ae3994abd7f70e75e69ae39/href">https://medium.com/media/2e6590583ae3994abd7f70e75e69ae39/href</a></iframe><h3>Conclusion</h3><p>Debouncing and throttling aren’t just fancy terms they’re essential for managing tasks efficiently. Whether it’s minimizing API calls with Google’s search bar or enhancing infinite scrolling on TikTok, these techniques improve performance and user satisfaction.</p><p>By learning GCD in Swift, we can implement these strategies effectively. Balancing user needs with performance demands ensures your app remains a delight to use fast, responsive, and reliable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8cee2c539b12" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Property Wrapper ile Firebase A/B Testing Kullanımı]]></title>
            <link>https://suleymantulburdev.medium.com/property-wrapper-ile-firebase-a-b-testing-kullan%C4%B1m%C4%B1-e2ca2e62cdda?source=rss-cf39c7da6d48------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2ca2e62cdda</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[utilities]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Süleyman Tülbür]]></dc:creator>
            <pubDate>Sat, 04 Jan 2025 21:52:12 GMT</pubDate>
            <atom:updated>2025-01-04T21:52:12.695Z</atom:updated>
            <content:encoded><![CDATA[<p>A/B testi, diğer adıyla split testing, modern uygulama geliştirmede sezgilerimizden ziyade veri odaklı kararlar almamızı sağlayan vazgeçilmez bir araç haline geldi. Mobil uygulamalar giderek daha karmaşık hale geldikçe, farklı özellikleri, kullanıcı arayüzlerini ve içerikleri test etme yeteneği, kullanıcı deneyimini optimize etmek ve ürün hedeflerine ulaşmak için çok önemli bir hal aldı.</p><p>Peki neden A/B testini uygulamaya zaman ayırmalıyız? Cevap, sağladığı değerli öngörülerde yatıyor. Kullanıcıların ne istediği hakkında varsayımlarda bulunmak yerine, A/B test senaryoları gerçek kullanıcı verileriyle doğrulamamıza olanak tanır. İster butonlarımız için farklı renk seçenekleri test ediyor olalım, ister çeşitli register akışlarını deniyor olalım, isterse farklı fiyatlandırma stratejilerini değerlendiriyor olalım, A/B testi kullanıcılarımızın istekleriyle bizim fikirlerimiz arasında neyin örtüştüğünü anlamamıza yardımcı oluyor.</p><p>Dahası, A/B testi uygulamanızın temel performans göstergelerini önemli ölçüde etkileyebilir. Varyasyonları sistematik olarak test ederek dönüşüm oranlarını optimize edebilir, kullanıcı edinimini artırabilir, kullanıcı kaybını azaltabilir ve sonuç olarak veriye dayalı bir şekidle daha iyi çıktılar elde edebilirsiniz. A/B testiyle metriklerde önemli iyileştirmeler görmek nadir değildir bazen küçük UI değişiklikleri bile kullanıcı ediniminde veya dönüşüm oranlarında iyileştirmelere yol açabilir.</p><p>Tüm bu gerekçelerden dolayı hem bireysel olarak geliştirdiğim uygulamada hem de iş hayatında geliştirdiğimiz uygulamalarda A/B testi sıklıkla kullanıyoruz. Bu yazıda ise iyi bir A/B testing kurgusu nasıl yapılmalıdır sorusundan ziyade Firebase ile A/B testlerimizi nasıl oluştururuz ve bunu efektif bir şekilde iOS uygulamamızda nasıl kullanırız sorularına odaklanacağım.</p><h4>Property Wrapper’ların Gücü</h4><p>Property Wrapper’lar, Swift’teki bir özelliktir ve temel olarak bir property’nin davranışını değiştiren, özelleştiren veya encapsule eden yapılar olarak tanımlanmaktadır. Swift 5.1&#39;de tanışmış olduğumuz bu özellik, belirli bir property üzerinde kod tekrarı olmadan tekrar kullanılabilir yapıların oluşturulmasını sağlar.</p><p>Bir property wrapper, belirli bir işlevi encapsule eder ve bunu, sınıf, struct veya enum içerisinde bulunan herhangi bir property’ye uygulayabiliriz. Property wrapper, @propertyWrapper etiketiyle tanımlanır ve wrappedValue özelliği üzerinden işlevsellik sunar.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/731e976a79556a2b0c91ea4aa12796a9/href">https://medium.com/media/731e976a79556a2b0c91ea4aa12796a9/href</a></iframe><ul><li>@propertyWrapper özelliği, bu structın bir property wrapper olduğunu belirtir.</li><li>wrappedValue özelliği, wrapper içindeki değeri tutar ve bu değeri almak veya ayarlamak için kullanılır.</li><li>Property wrapper, kendi init(wrappedValue:) metodu ile initialization yaparak, property&#39;ye bir değer atanmasını sağlar.</li></ul><p>Firebase A/B testleri Firebase Remote Config üzerinden yürütülmektedir. Firebase Remote Config üzerinde tanımlanan key-value çiftleri A/B test variyantlarımıza göre bizim önden belirlemiş olduğumuz dağıtım oranı göz önünde bulunudurularak rastgele bir şekilde Firebase SDK tarafından getirilir.</p><p>Tam da bu noktada hem istediğimiz bir key’e karşılık gelen değeri hem de olası hata durumlarında bu özelliğe ekstra bir error handling mekanizması eklemeden belirlediğimiz bir default değeri atayabileceğimiz bir yapı kurguluyorduk. Ayrıca bu yapıdaki değeri kullanmak için ekstra bir extract işlemi yapmadan kolayca uygulamanın her yerinde kullanmamız gerekiyordu. Bizi bu amaca ulaştıran birçok yapıyı denemiş olmamıza rağmen elde ettiğimiz sonuçlar istediğimiz esnekliğin uzağındaydı. Çünkü temelinde yapmamız gereken işlem bir manager sınıfı yazıp birkaç fonksiyon yardımıyla bu değerleri sürekli bir logic sınıfı içerisinde okumamız gerekiyordu. Temelinde çok basit olan bu operasyon sınıf ve A/B test senaryolarımız arttıkça kodumuzun daha karmaşık hale gelmesine yol açtı. Bu nedenle bu operasyonu daha basit, esnek ve ihtiyaçlarımıza daha kolay cevap verecek başka bir yöntemle çözmemiz gerektiğini düşündük.</p><p>Bu aşamada yukarıda da değinmiş olduğum Property Wrapper’ları kullanma kararı aldık.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e2026f652e9b0cd991a6b235bfb68760/href">https://medium.com/media/e2026f652e9b0cd991a6b235bfb68760/href</a></iframe><h4>Örnek Kullanım:</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b84e223825d2eab867ba087f0bb25aef/href">https://medium.com/media/b84e223825d2eab867ba087f0bb25aef/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2ca2e62cdda" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[iOS’de HTTP Caching Stratejileri v1.0]]></title>
            <link>https://suleymantulburdev.medium.com/iosde-http-caching-stratejileri-6d0dc23d7228?source=rss-cf39c7da6d48------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d0dc23d7228</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[https]]></category>
            <dc:creator><![CDATA[Süleyman Tülbür]]></dc:creator>
            <pubDate>Sun, 25 Aug 2024 17:35:03 GMT</pubDate>
            <atom:updated>2025-01-04T14:23:57.100Z</atom:updated>
            <content:encoded><![CDATA[<h4>URLCache Temelleri</h4><p>Yakın zamanda geliştirdiğim bir uygulamada, yüksek boyutlu verilerle çalışırken sunucudan istemciye veri aktarımı sırasında trafik ve kaynak kullanımı gibi sorunlarla karşılaştım. Uygulamamdaki belirli bir ekran her açıldığında, işlemleri sağlayan servise sürekli olarak istek göndermem gerekiyordu. Bu ekran ayrıca, pull to refresh özelliğini barındırıyordu. Listelemedeki bir işlemin detayına girip düzenleme yaptıktan sonra, geri dönüp listeleme sayfasını yeniden yenilemem gerekiyordu. Bu süreçlerin sonunda, kullanıcılarıma sürekli bir yükleme (loading) ekranı gösterdiğim için olumsuz bir deneyim sundum. Ayrıca, artan I/O kullanımı nedeniyle maliyetlerimde artış yaşadım ve rate limiting gibi problemlerle karşı karşıya kaldım.</p><p>Bu problemler sonucunda, uygulamamda servis isteklerini cachelemenin yaşadığım sorunların etkisini en aza indirebileceğine karar verdim. Bu nedenle, servis isteklerini nasıl cacheleyebileceğim konusunda çeşitli yöntemler araştırmaya başladım.</p><p>Servis isteklerini cacheleyebilmek için Swift’te birçok alternatif mevcut. NSCache, UserDefaults, CoreData gibi yapılar bu istekleri cachelemek için iyi çözümler sunuyor. Ben de uygulamamda ilk aşamada bu yöntemleri kullandım. Aslında, yapmak istediğim her şeyi başarıyla gerçekleştirdim; ancak kodumu gözden geçirdiğimde, bu yapıların basit bir cache işlemi için projeme çok fazla karmaşıklık kattığını fark ettim. Bu problemlerin başında manuel kontroller geliyordu. Yeni bir servis isteği yaptığımda, mevcut cache’in doğrulanması, güncellenmesi ve silinmesi gibi işlemler çok fazla logic içeriyordu. Dahası, aynı anda birden fazla istek atmam gereken senaryolarda bu logiclerin doğru çalışıp çalışmadığını test edebileceğim yeterli test süitine sahip değildim. Uygulamamdaki tüm servislere bir cache mekanizması eklemeyi düşündüğümde, bakım maliyetlerinin artacağını fark ettim ve yeni bir alternatif arayışına başladım.</p><h4>URLCache</h4><p><a href="https://developer.apple.com/documentation/foundation/urlcache">UrlCache</a> servis isteklerini cacheleyebilmemiz için Apple’ın Foundation framework’ü tarafından sağlanan bir http caching mekanizmasıdır. Request’leri ve servis isteklerinden alınan cevapları hızlı ve basit bir şekilde cacheleyebilmemiz için birçok özellik sağlamaktadır.</p><h4>Built-in Özellikler</h4><ul><li>Hem otomatik hem de manuel bir şekilde cachlerin yazılması ve okunması işleminin yapılabilmesi.</li><li>Hem memory’de hem de disk’te cachelerin barındırılabilmesi.</li><li>Her servis için kolayca cache sınıflarının konfigüre edilebilmesi.</li><li>Cache’lerin otomatik olarak doğrulanabiliyor olması.</li><li>Farklı senaryolara göre <a href="https://developer.apple.com/documentation/foundation/urlsessionconfiguration/1411655-requestcachepolicy">Cache Policy</a>’lerin yapılandırılabilmesi.</li><li>Internet’in olmadığı senaryolarda cachelerin otomatik olarak yüklenebilmesi.</li></ul><p>URLCache manuel yapılan birçok işlemi otomatize ettiği için manuel cache sınıflarının yarattığı karmaşıklığı azaltıyor. Bu özelliklere daha fazla özelleştirme aranan senaryolarda kullanılması çok uygun olmayabilir. Ayrıca memory ve disklerin doğru bir şekilde yapılandırılmadığı durumlarda cachelerimizin kaybolması gibi tehlikelerle karşı karşıya kalabiliriz.</p><h4>URLCache’in yapılandırılması</h4><h4>Default</h4><p>URLCache birçok farklı senaryoda yapılandırma senaryosuna sahip olabilir. URLCache’in temel yapılandırması aşağıdaki gibidir.</p><p>memoryCapacity: URLCache’in memory’de sahip olacağı alan. (Byte)</p><p>diskCapacity: URLCache’in disk’te sahip olacağı alan. (Byte)</p><p>diskPath: Disk barındırılacağı yol. Default ayarında bırakmak için nil verilebilir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3bwKYmuuiZfjbGS0tmUtfA.png" /></figure><p>Yukarıdaki yapılandırma birçok senaryoda işe yarasa da cache’lerin birbirinden ayrı yerlerde barındırılması ve yönetilebilmesi için URLCache sınıfları ayırılabilir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y05MN9omfnQgRveqOqUKXw.png" /></figure><h4>Örnek Uygulama</h4><p>URLCache kullanarak örnek bir uygulama yaparak pratiklerimizi pekiştirelim. Uygulama basitçe bir RESTful servisten Post’ları alacak. Bunun için Express.JS ile basit bir servis yazalım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AbHplV0sGbjdlsnaSliQsQ.png" /></figure><p>Görüldüğü üzere servis iki endpointten oluşuyor. Endpointlerden bir tanesi postlarımızı getirirken diğeri de yeni bir post ekliyor.</p><p>GET /posts’a baktığımızda Header’da “Cache-Control” parametresi dönüyor. Bu parametre, caching işleminin nasıl yapılacağını belirtmek için kullanılır. max-age=60 değeri ile de isteğin cache’te kaç saniye tutulacağını belirtiyoruz. <a href="https://web.dev/articles/http-cache?hl=tr">Http Caching</a> hakkında daha fazla detay’ı araştırmanızı öneririm. Bu Header’ı dönme amacımız aşağıda bahsettiğim Cache Policy’ler için önemli bir nokta olacak.</p><h4>Mobil Uygulama</h4><p>Mobil uygulama çok basitçe bir ekrandan oluşuyor, ekranda postları listelediğimiz bir UITableView ve Yenile butonu bulunuyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ynB7-AUlVb7lyfktrU7Q9Q.png" /></figure><p>Şimdi herhangi bir cache mekanizması olmadan servis isteğini oluşturup servisimizden verileri alalım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EdPEYK3A2eVhw9omT0NWbA.png" /></figure><p>Yenile butonuma tıklıyorum ve görüldüğü üzere sunucumun loglarına birer saniye aralıklarla bu istekler düşmeye devam ediyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/302/1*U6wvtJ3gTLHFqBqq3U3KKQ.png" /></figure><p>Şimdi cache mekanizmamızı yapılandıralım. Yapılandırma bölümünde bahsettiğim PostsCache sınıfından devam edeceğim ve fetchPosts isteğimi cache sınıfımla beraber revize ediyorum.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j1nEpYvk1mZyxBZwe79R7g.png" /></figure><p>Şimdi istekleri atıp sonuçlara bakabiliriz.</p><p>19.56–19.57 arasında geçen bir dakikalık sürede 13 adet istek gönderdik bu isteklerin ilki 19.56:21&#39;de sunucuya ulaşırken, sonuncusu 19.57:28&#39;de sunucuya ulaştı. Arada gerçekleşen 11 istek ise sunucuya ulaşmadan direkt cache’den okundu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0dpDRU5G_T0sNL3e8kOLsQ.png" /><figcaption>19.56–19.57 Arasında gerçekleşen istekler</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*8I8wXZelyVHoaW_vlS3ZcA.png" /><figcaption>Sunucuya ulaşan istekler</figcaption></figure><h4>Cache Policies</h4><p>Caching stratejimize uygun olarak kullanabileceğimiz altı farklı Cache Policy bulunmakta.</p><ol><li>useProtocolCachePolicy</li></ol><p>HTTP Protokolünün caching betimlemelerini kullanır. Bunları yaparken “Cache-Control”, “ETag” ve “Expires” gibi Header değerlerini kullanır. Varsayılan olarak uygulanan policydir.</p><p>2. reloadIgnoringLocalCacheData</p><p>Sadece yerelde bulunan cacheleri gözardı ederek kaynaktan yeni veri almak için kullanılır.</p><p>3. reloadIgnoringLocalAndRemoteCacheData</p><p>Yerelde veya uzakta bulunan cacheleri gözardı ederek her zaman kaynaktan yeni veri almak için kullanılır.</p><p>4. returnCacheDataElseLoad</p><p>Önce cacheteki veriler kullanılmaya çalışılır eğer cachete bir veri yoksa veya kullanılamıyorsa kaynaktan yeni veri almak için kullanılır.</p><p>5. returnCacheDataDontLoad</p><p>Sadece cacheteki verileri getirmek için kullanılır. Eğer cachede bir veri yoksa kaynağa gidip yeni veri almaz ve hata verir.</p><p>6. reloadRevalidatingCacheData</p><p>Cacheteki veriler kaynak tarafından doğrulanabiliyorsa cacheteki verileri kullanır, kullanılamıyorsa kaynaktan yeni veri alınır ve cache güncellenir.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d0dc23d7228" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>