Skip to content

ApplicationAssets Sınıfının Yapımı #45

@gdemir

Description

@gdemir

Assets altındaki dosyalarda güncelleme olduğunda tarayıcı tarafından daha önceki dosyaların önbellekte tutulmasını engellemek için kullanılacak sınıf. Bu sınıf,

http://.../assets/css/default.css?123
http://.../assets/css/default.css?156

mantığıyla ? sonrası gelen rakam değiştiği takdirde tekrar yüklemeye zorlamasıyla çalışmaktadır.

class ApplicationAssets {

	const ASSETSPATH = "/app/assets/";

	public static function css($file) {
		$file = self::ASSETSPATH . "css/" . $file;
		return self::_no_cache($file);
	}

	public static function js($file) {
		$file = self::ASSETSPATH . "js/" . $file;
		return self::_no_cache($file);
	}

	public static function font($file) {
		$file = self::ASSETSPATH . "font/" . $file;
		return self::_no_cache($file);
	}
	
	private static function _no_cache($file) {
		return $file . "?" . md5(filemtime($file));
	}
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions