You can file for divorce as soon as either you or your spouse meets the residency requirements of the state and county that you plan on filing in. More specifically a party must be a domiciliary of the state for the preceding 6-month period. A domiciliary of the state means a person that primarily lives in that state.
Second, a party must be a resident of the county in which the suit is filed for the preceding 90-day period. However, a spouse that does not live in the state may file a case against a spouse that does live in the state, as long as that spouse meets both of the requirements stated above.