Can any one explain me the difference between GhostableInLibrary and Ghostable files, also what are prons and cons for each one?
In SharePoint, any file (outside _layouts: _layouts is a huge exception to what's following here) is either "ghosted" or "unghosted".
"Ghosted" means the file source (content) is stored on the disk of each SharePoint server (WFE) of the farm.
Whenever a user requests a page from SharePoint, and the page is ghosted (and marked as ghosted in the DB, along with its physical path), the file is taken from the disk and then served to the client.
If the user requests an unghosted page, it means the content of the page is stored in the SQL DB, and the SharePoint server has to get that content from the DB to serve it to the client (actually, a memory cache mechanism enters the game, so the SharePoint server doesn't always request the entire page content from SQL if there was no change in it).
Initially, default/OOTB SharePoint pages are ghosted (i.e. on the disk of each WFE). Also, you may have different files in different libraries (including Pages or SitePages libraries) that actually refer to the same physical version of the file on the disk.
As soon as you edit a file (from SharePoint Designer for .aspx pages, or from Word for .docx, etc.), that file becomes unghosted. [note: you can de-unghost it (!) from SPD]
Of course, when you upload a new file into a library (the most common scenario for end-users), it's naturally unghosted (i.e. sent immediately to SQL, never written on disks of WFE), and there's no way to "de-unghost" (aka "re-ghost") it.
Also, as the file resides in a document library, it supports all the library features (it has an associated item with meta-data, versioning, etc.).
The file is said to be "in library".
When you develop a custom solution, and create "modules" to populate files at feature-activation, your files are naturally "ghosted" since you have a physical copy of them that will be deployed on the disk of each WFE (in the 14, or 15 or 16 hive). But you still have the choice between "ghosted" and "ghosted in library".
"ghosted in library" will be the choice most of the time, since it means your new files will behave exactly as if they were uploaded by an end-user (they'll have an associated item, metadata, properties...) (the only slight difference is that they can be re-ghosted after unghosting, while real end-users files are always plain unghosted).
"ghosted" will be the choice if you want the file to be stored in the library; but the file will be kind-of "hard-coded" (or let's say "static"), with no normal library features. You'll choose that option for code files like .aspx forms, if you want.
Solution-1 : Source
The decision between Ghostable and GhostableInLibrary really is based on the type of file that you are deploying and whether you want users to view and access the document view a list or a library.
If you desire users to view the file within a library then you would select the InLibrary option. Both Ghostable / GhostableInLibrary implies that the file will be cached in memory.
GhostableInLibrary however specifies that the file be cached as part of a list whose base type is
Document Library and that you can work with the file as you would with any other file in the library (check-in, check-out, version history).
Solution-2 : Source
Ghostable and GhostableInLibrary Specifies that the file be cached in memory on the web front end. Both values specify that the file be cached,
GhostableInLibrary specifies that the file be cached as part of a list whose base type is Document Library and that you can work with the file as you would with any other file in the library and provides you same features like check-in, check-out, version history etc.
When changes are made to those files only the differences from the original page definition are stored in the database, while original file is cached in memory along with the schema files. The HTML page that is displayed in the browser is constructed through the combined definition resulting from the original definition cached in memory and from changes stored in the database.
Both values specify that the file will be cached, but GhostableInLibrary specifies that the file will be cached as part of a list whose base type is
If you don't set a value this means that the file is Unghostable implying that the file will not be cached in memory in web front end servers and that it'll be completely stored in the database.
If you need to understand the difference in terms of Programming context then please refer Ghostable vs. GhostableInLibrary – A Lesson on Custom Form Deployment in SharePoint